how get a list(array data type) from script console

how get a list(array data type) from script console

KORLOY_KMH
Not applicable
2 Views
3 Replies
Message 1 of 4

how get a list(array data type) from script console

KORLOY_KMH
Not applicable

[ FlexSim 25.0.2 ]

Hello.


I need to move multiple processors. To do this, I will obtain a list of all processors from the entire system and use an accompanying global list from Excel which contains information about their original and new positions. During the loop, I'll update the processor locations accordingly.


If it have to seperate steps like below

- get all object

- judge where is it processor or not


anyone help this job for me ?


0 Likes
Accepted solutions (1)
3 Views
3 Replies
Replies (3)
Message 2 of 4

moehlmann_fe
Observer
Observer
Accepted solution

You can check the class name to determine whether it's an object is a processor. The example code below would return an array that contains all processors in the model.

Array processors = [];
forobjecttreeunder(model()) {     treenode obj = a;     if(obj.dataType == DATATYPE_OBJECT && objectexists(classes(obj)) && classes(obj).first.name == "Processor")     {         // Object is a processor -> do stuff         processors.push(obj);     } } return processors;
Message 3 of 4

jason_lightfootVL7B4
Autodesk
Autodesk

Or, you could use:

Table t=Table.query("SELECT ARRAY_AGG(Object) FROM Objects() WHERE Class='Processor'");
if (t.numRows)
    return  t[1][1];
return [];

And if you know you have processors in the model it would be just:

Table.query("SELECT ARRAY_AGG(Object) FROM Objects() WHERE Class='Processor'")[1][1];
Message 4 of 4

KORLOY_KMH
Not applicable
Thanks a lot :)
0 Likes