How can I obtain the path that the AGV is traveling along at that moment?

How can I obtain the path that the AGV is traveling along at that moment?

1978353512
Contributor Contributor
343 Views
5 Replies
Message 1 of 6

How can I obtain the path that the AGV is traveling along at that moment?

1978353512
Contributor
Contributor

I want to obtain the current path reference that the AGV is following using code. How should I write the code? Advance thanks。ScreenShot_2026-01-13_092441_071.png

0 Likes
Accepted solutions (2)
344 Views
5 Replies
Replies (5)
Message 2 of 6

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

You can access the current travel path section through the AGV class. This in turn lets you access which path object the section belongs to.

https://docs.flexsim.com/en/26.0/Reference/CodingInFlexSim/FlexScriptAPIReference/AGV/AGV.html#Prope...

https://docs.flexsim.com/en/26.0/Reference/CodingInFlexSim/FlexScriptAPIReference/AGV/AGV.TravelPath...

AGV(object).currentTravelPathSection.path
0 Likes
Message 3 of 6

1978353512
Contributor
Contributor

Hello moehlmann_fe,I have another question. Can I know which path the AGV is on within the tree node? If there are two identical paths in the AGV path array, then "AGV(object).currentTravelPathSection.path" may cause an error. So I want to determine which path the AGV has reached by accessing the tree nodes. How can I achieve this? By giving thanks in advance.

ScreenShot_2026-01-20_102327_061.png

0 Likes
Message 4 of 6

FelixMoehlmann
Collaborator
Collaborator

Can you provide an example model where the expression causes an error?

Getting the node the AGV is currently at in its travel is exactly what "currentTravelPathSection" does. The return value is cast as an AGV.TravelPathSection variable, so ".path" gets the corresponding path object (value of node). So the answer stays the same.

0 Likes
Message 5 of 6

1978353512
Contributor
Contributor

Sorry, I didn't explain my problem clearly. The code "AGV(object).currentTravelPathSection.path" can solve the problem I had before. I'm going to elaborate on my new problem. For a simple example, the path array for an AGV's movement is [Path1, Path2, Path3, Path4, Path1], which consists of 5 segments of paths. When the AGV reaches the fifth section of the path, using "currentTravelPathSection" allows us to obtain Path1. I want to determine at which section of the path the AGV is currently located. When I use PathArray.indexof(Path1), the returned index is 1, which will cause subsequent errors. So, whether it is possible to quickly determine through the tree node or other methods which path the AGV is currently on in its path array, I need to obtain the correct index.

0 Likes
Message 6 of 6

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

"currentTravelPathSection" gets the current travel section node (cast as AGV.TravelPathSection, as I mentioned). You can still treat is as a treenode and get its rank.

AGV(obj).currentTravelPathSection.as(treenode).rank

 

0 Likes