Retrieve all nodes connected to a network node via code

Retrieve all nodes connected to a network node via code

rohan_v3
Not applicable
50 Views
4 Replies
Message 1 of 5

Retrieve all nodes connected to a network node via code

rohan_v3
Not applicable

[ FlexSim 21.0.4 ]

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.


38624-1618602555514.png

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

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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

0 Likes
Message 3 of 5

rohan_v3
Not applicable

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
Message 4 of 5

jason_lightfootVL7B4
Autodesk
Autodesk

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

0 Likes
Message 5 of 5

rohan_v3
Not applicable

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

0 Likes