question

Chris Smith avatar image
1 Like"
Chris Smith asked Phil BoBo edited

How to create and join AVG paths in flexscript

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);
}
Choose One
flexscriptagv pathpathagv connection
· 1
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

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 0 ·

1 Answer

·
Phil BoBo avatar image
10 Likes"
Phil BoBo answered Phil BoBo edited

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);
}
5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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