question

Rohan V3 avatar image
0 Likes"
Rohan V3 asked Rohan V3 commented

Retrieve all nodes connected to a network node via code

Trying to get all the nodes connected to a given network node. I want to store them in an 'Object' variable and use for further logic. I explored the tree to see if I can sample something but couldn't find it. the 'connectionsout' node cant be used for sampling the connections.


FlexSim 21.0.4
flexscriptnetwork nodeflexsim 21.0.4
1618602555514.png (37.3 KiB)
5 |100000

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

1 Answer

·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Rohan V3 commented

Connections out will work - a simple recursive function will do what you want.

· 3
5 |100000

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

Rohan V3 avatar image Rohan V3 commented ·

Was able to do it with following code. Needed to slice the string to take the 'To' out and obtain object name.

Array array = Model.find("Floor_1Cross_1_2").find(">connections/connectionsout").subnodes.toArray();
string obnum = array[1].name;
int length = obnum.length;
string obnum_new = obnum.slice(4,length+1);
Object nn = Model.find(obnum_new);

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Rohan V3 commented ·

You could just use outObjects or the value of the connection node and finding the ownerobject of that.

0 Likes 0 ·
Rohan V3 avatar image Rohan V3 Rohan V3 commented ·

Yeah.. for some reason I thought out objects wouldnt work.. Well then its a very easy problem.. Haha.. nevermind then... Thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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