How to list(write) all NetworkNodes between two NetworkNodes?

How to list(write) all NetworkNodes between two NetworkNodes?

kim_jh
Not applicable
3 Views
2 Replies
Message 1 of 3

How to list(write) all NetworkNodes between two NetworkNodes?

kim_jh
Not applicable

For example, in this situation, NN1 ↔ NN2 ↔ NN3 ↔ NN4 ↔ NN5. command1(NN1, NN5) writes as follows NN1, NN2, NN3, NN4, NN5

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

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

The key here is to use the getnextnetnode() command. The tricky thing is that this command takes network node ranks as inputs and returns the rank of the next network node between the 2 you specify. So we will also have to use the rankfromnetnodeI() and netnodefromnode() commands to convert back and forth between the rank of the node and the node itself.

Here's the code:

treenode startNode = node("MODEL:/NN1");
treenode endNode = node("MODEL:/NN7");
int start = rankfromnetnode(startNode);
int end = rankfromnetnode(endNode);
int cur = start;

while(cur != end) {
	pt(getname(netnodefromrank(cur))); pr();
	cur = getnextnetnode(cur, end);
}

pt(getname(endNode));


Matthew Gillespie
FlexSim Software Developer

Message 3 of 3

Matthew_Gillespie
Autodesk
Autodesk

And make sure you reset the model before running this script so that the network's distance table is up to date.



Matthew Gillespie
FlexSim Software Developer

0 Likes