question

SudheerReddy avatar image
0 Likes"
SudheerReddy asked tannerp answered

How to get Coordinates of AGVNetwork through Code.

As shown in below image I drawn simple AGV paths. I would like to get the coordinates of all paths through code. How to achieve this?

Any feedback on this.

Attaching the model for reference.

AGVCoord.fsm

FlexSim 20.1.0
flexsim 20.1.0
agvcoord.fsm (26.6 KiB)
agvcoord.jpg (48.8 KiB)
· 2
5 |100000

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

tannerp avatar image tannerp commented ·

Hi @Sudheer R, was Jörg Vogel's answer helpful? If so, please click the red "Accept" button on their answer. If not, feel free to comment back with more information and we'll provide further support. Thanks!

0 Likes 0 ·
SudheerReddy avatar image SudheerReddy tannerp commented ·

@tanner.p I'm trying to find coordinates of all control points through script. Could you please guide me

0 Likes 0 ·

1 Answer

tannerp avatar image
0 Likes"
tannerp answered

In Jörg's answer, he points out where to find the coordinates in the tree. You can use a sampling tool in the Script window to get the values of these nodes as shown in the gif below. The "spatialx" and "spatialy" values make up the start point of the path, then the "spatialsx" and other values are vectors that give the magnitude (length) of the path in that direction.

The code is as follows:

Model.find("AGVNetwork/Path1").as(Object).location.x //Start location (x)

Model.find("AGVNetwork/Path1").as(Object).size.x //Vector magnitude (x)

Hopefully this helps.


· 2
5 |100000

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

SudheerReddy avatar image SudheerReddy commented ·

@tanner.p thanks for your answer. Like if I have more than 10 control points instead of using sampler every time any loop logic?

0 Likes 0 ·
tannerp avatar image tannerp SudheerReddy commented ·

Yes, you can implement a loop if you'd like. Just parse through each of the AGVNetwork subnodes. Something like this:

for(int i=1; i<Model.find("AGVNetwork").subnodes.length; i++) {
   print(Model.find("AGVNetwork").subnodes[i].as(Object).location.x);
}
0 Likes 0 ·