question

royjuventus29 avatar image
0 Likes"
royjuventus29 asked royjuventus29 commented

How to get all "A" connections between Objects in Flexsim script?

FlexSim 24.0.1
flexsim script
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered royjuventus29 commented
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

royjuventus29 avatar image royjuventus29 commented ·
This is to create the connections. Do you know how to get all of the connections in the entire model?
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann royjuventus29 commented ·

I think you'd have to loop through all objects in the group and store the connection info somewhere. That could look something like this:

Table connectionTable = Table("Test");
connectionTable.setSize(0, 2); connectionTable.setColHeader(1, "From"); connectionTable.setColHeader(2, "To"); int row = 0; forobjecttreeunder(model()) {     treenode curNode = a;     if(curNode.dataType == DATATYPE_OBJECT)     {         Object curObject = curNode;         for(int i = 1; i <= curObject.outObjects.length; i++)         {             connectionTable.addRow();             row++;             connectionTable[row][1] = curObject.name;             connectionTable[row][2] = curObject.outObjects[i].name;         }     } }
1 Like 1 ·
royjuventus29 avatar image royjuventus29 Felix Möhlmann commented ·

Hi, I have tried your code. There is an error "exception: FlexScript exception: Invalid column number: 1 in <no path> at VIEW:/active/MainPanel/ToolPanel/UserPanel/usertoolbar" when it is executed to:

connectionTable.setColHeader(1, "From");

Do you know how to fix this issue?

0 Likes 0 ·
Show more comments
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot edited

To record and recreate connections you can use the Objects() table that describes the model. Here's the scripts to use a global table called 'connections'

Record example:

Table.query("SELECT Object, InObjects FROM Objects() WHERE InObjects IS NOT NULL").cloneTo("connections")


Re-create recorded connections:

Table.query("UPDATE  Objects() a INNER JOIN connections b ON b.Object=a.Object SET a.InObjects=b.InObjects");


You should be able to do the same using OutObjects and CenterObjects properties.

You can read more about using SQL with object properties here.

Note that you can also construct models from tables using the INSERT INTO Objects() clause with the relevant property fields - where you include the class or an object to copy from (as described here) .

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.