How to create and join AVG paths in flexscript

How to create and join AVG paths in flexscript

chris_smith7
Not applicable
210 Views
2 Replies
Message 1 of 3

How to create and join AVG paths in flexscript

chris_smith7
Not applicable

I know I can create paths by doing the following:

createinstance(node("/AGV/StraightPath",library()),model());

However, once created, sized, and positioned the paths are not connected. I tried to use the code from the join path edit mode, but was unable to reliably create good connection paths. Is there a good way to do this? The following is the code I am using to test the concept:

treenode path1 = createinstance(node("/AGV/StraightPath",library()),model());
treenode path2 = createinstance(node("/AGV/StraightPath",library()),model());
setsize(path1,3,1,1);
setsize(path2,8,1,1);
setloc(path1,1,0,0);
setloc(path2,5,1,0);
setrot(path2,0,0,90);
treenode from = path1;
treenode to = path2;
if (isclasstype(from, "AGV::Path") && isclasstype(to, "AGV::Path")) {
    double distAlongFrom = 2.85;
    double distAlongTo = 0.16;
    treenode newPath = applicationcommand("Path_joinTo", from, to, distAlongFrom, distAlongTo);
}
Accepted solutions (1)
211 Views
2 Replies
Replies (2)
Message 2 of 3

joerg_vogel_HsH
Mentor
Mentor

It isn't the direct answer, but it should tell you the module functions are bit different than the 3D model command structure. Here is an example for another answer with the AGV module and script generated connections.

0 Likes
Message 3 of 3

philboboADSK
Autodesk
Autodesk
Accepted solution

You should call function_s(path, "finalizeSpatialChanges") after creating or moving an AGV path using code:

treenode path1 = createinstance(node("/AGV/StraightPath",library()),model());
treenode path2 = createinstance(node("/AGV/StraightPath",library()),model());
setsize(path1,3,1,1);
setsize(path2,8,1,1);
setloc(path1,1,0,0);
setloc(path2,5,1,0);
setrot(path2,0,0,90);
function_s(path1, "finalizeSpatialChanges");
function_s(path2, "finalizeSpatialChanges");
treenode from = path1;
treenode to = path2;
if (isclasstype(from, "AGV::Path") && isclasstype(to, "AGV::Path")) {
    double distAlongFrom = 2.5;
    double distAlongTo = 0.16;
    treenode newPath = applicationcommand("Path_joinTo", from, to, distAlongFrom, distAlongTo);
}


Phil BoBo
Sr. Manager, Software Development