Das Wissen aller Anwender nutzen

Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.

Es erwarten Sie:

  • Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
  • Tipps von User für User
  • international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch

Melden Sie sich jetzt an und diskutieren Sie mit!

Zur Registrierung

[Frage] List of Tuples [Gelöst]


Hi everyone.
I would like to search in a list of tuple and find a value corresponding to a specific index, is there anyone who can explain to me how to access tuple?

In particular, I'm trying to access the tuple list generated from GetObjectAttributes node.

Thanks in advance for any suggestion!

Anhänge (1)

Typ: image/jpeg
173-mal heruntergeladen
Größe: 210,19 KiB

Lösung anzeigen Lösung verbergen

Currently, it seems we don't have the node for access a normal tuple. We only have one for named tuple...

But for this you can try to write py code. Copy & paste the code below into the node "ExecPythonScript" and connect both tuple lists and index value to the 'parameter' of that node. Make sure you first connect the tuple list and then the index, because the order does matter. You should be able to get the results you want. (Make sure the number of list levels is the same as shown in your screenshot, otherwise it won't work.)

def function_to_execute(tuple_list,search_value):   
    result = []
    result.extend([t[1] for t in tuple_list if t[0] == search_value])
    return result

This code just does what you describe. If the 1st value in the tuple is equal to the index you provide, it will then return the 2nd value of the tuple back.
For more info, please check the screenshot attached.

Product Owner API, Allplan GmbH

Anhänge (1)

Typ: image/png
184-mal heruntergeladen
Größe: 65,43 KiB

Currently, it seems we don't have the node for access a normal tuple. We only have one for named tuple...

But for this you can try to write py code. Copy & paste the code below into the node "ExecPythonScript" and connect both tuple lists and index value to the 'parameter' of that node. Make sure you first connect the tuple list and then the index, because the order does matter. You should be able to get the results you want. (Make sure the number of list levels is the same as shown in your screenshot, otherwise it won't work.)

def function_to_execute(tuple_list,search_value):   
    result = []
    result.extend([t[1] for t in tuple_list if t[0] == search_value])
    return result

This code just does what you describe. If the 1st value in the tuple is equal to the index you provide, it will then return the 2nd value of the tuple back.
For more info, please check the screenshot attached.

Product Owner API, Allplan GmbH

Anhänge (1)

Typ: image/png
184-mal heruntergeladen
Größe: 65,43 KiB

Great, this is what I needed!
Thanks


https://campus.allplan.com/ verwendet Cookies  -  Mehr Informationen

Akzeptieren