cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AGV Network Split Paths Tool

AGV Network Split Paths Tool

Hi,

when creating models using AGV network, I have often encountered situations where certain behaviors or path restrictions become better defined during development. Since the layout has already been created without this information, it sometimes means that certain paths need to be divided into multiple segments, that is, into several path objects, in order to define different characteristics within them.

It would be highly beneficial to have a tool that can automatically divide a single path into multiple segments, allowing users to define a cutting point, for example.

Thanks in advance!

9 Comments
That would indeed be super useful. We have made different user commands in different models to cut AGV paths. But that was always under some assumptions, such as that the path was not rotated, or assumptions about the travel direction. Keeping all the control point on their original place is a must I think when cutting paths.

Here's a script/command you can test that uses a percentage of the original length for the split point:

Object path=Model.find("AGVNetwork/Path1");   //param(1)
double splitPercent=50;                               //param(2)
Vec3 startLoc=path.getProperty("StartLocation");
Vec3 endLoc=path.getProperty("EndLocation");
Vec3 vec=endLoc-startLoc;
double magnitude=vec.magnitude;
double shortlen=magnitude*splitPercent/100;
Vec3 midLoc=startLoc+vec.normalized*magnitude*splitPercent/100;
treenode temp=nodeinsertinto(Model.find("Tools"));
Table.query("SELECT * FROM Objects() WHERE Object=$1",path).as(Table).cloneTo(temp);
Table(temp)[1]["StartLocation"]=midLoc;
Table(temp)[1]["Name"]+="_new";
Table.query("INSERT INTO Objects() (Class, Container, Name, StartLocation, EndLocation, PathClass, AGVOrientation, AccumulationType) SELECT Class, Container, Name, StartLocation, EndLocation, PathClass, AGVOrientation, AccumulationType FROM $1",temp);
temp.destroy();
Object newpath=path.up.last;
treenode points=getvarnode(path,"pathPoints");
treenode tcs=getvarnode(path,"transferClusters");
treenode newPoints=getvarnode(newpath,"pathPoints");
treenode newTCs=getvarnode(newpath,"transferClusters");
treenode point=points.last;
Object cp;
while (point && point.subnodes["distAlong"].value>shortlen){
    point.up=newPoints;
    point.subnodes["distAlong"].value-=shortlen; 
   //treenode tc=point.value.up.up;  
   // if (tc&&tc.up==tcs)   // do I need to move transfer clusters?
//tc.up=newTCs;
//cp=findownerobject(point.value);
//if (cp.getProperty("Class")=="AGV::ControlPoint")   // re-finalize control points?
//  function_s(cp,"finalizaSpatialChanges");
    point=points.last;
}
setvarnum(path,"length",shortlen);
path.setProperty("EndLocation",midLoc);
setcursor(3);
function_s(path, "refreshAllPathLinks", 0);
function_s(path, "refreshAllPathLinks", 0);  //twice
setcursor(1);

Alternatively you could specify a coordinate and change the code to project that onto the line at 90 degrees to find the intersection point.

iago_mf
Not applicable

Thanks Jason! This works with straight paths. Control points move but this can be solved.

In my small test the control points and areas were transferred correctly. Can you share your test? It's just different logic to find the midpoint of a curve based on the sweep angle and start angle - should be simple enough - the location and radius will be the same.

iago_mf
Not applicable

This is the layout i've tested in FlexSim 23 Update 1:

1693812669903.png

And this is the result: 1693812711007.png

I attach the model

23.1 Split Paths Test.fsm

I added line 25 above which keeps the control point positions, but for some reason shifts the transfer cluster location - perhaps a quirk of them coinciding.

setvarnum(path,"length",shortlen);
Paula_LG
Enthusiast
Hi Jason,


While trying to implement this code, I realized that there's a spelling mistake on line 22; it says "finalizaSpatialChanges", instead of "finalizeSpatialChanges". When I changed it, FlexSim wasn't able to run the code and it shut down. Any thoughts on why this happens?

Thank you in advance!

It looks like that's not needed from the most recent test. I've updated the script above to reflect that and included the correct (now commented) references to path point objects. Also commented is code where I tried moving the transfer clusters in case that was needed but I think refreshAllPathlinks takes care of those for us.
iago_mf
Not applicable
Now it's working fine. Thank you Jason!

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea