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:

  1. 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:

  1. treenode path1 = createinstance(node("/AGV/StraightPath",library()),model());
  2. treenode path2 = createinstance(node("/AGV/StraightPath",library()),model());
  3. setsize(path1,3,1,1);
  4. setsize(path2,8,1,1);
  5. setloc(path1,1,0,0);
  6. setloc(path2,5,1,0);
  7. setrot(path2,0,0,90);
  8. treenode from = path1;
  9. treenode to = path2;
  10. if (isclasstype(from, "AGV::Path") && isclasstype(to, "AGV::Path")) {
  11. double distAlongFrom = 2.85;
  12. double distAlongTo = 0.16;
  13. treenode newPath = applicationcommand("Path_joinTo", from, to, distAlongFrom, distAlongTo);
  14. }
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.

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:

  1. treenode path1 = createinstance(node("/AGV/StraightPath",library()),model());
  2. treenode path2 = createinstance(node("/AGV/StraightPath",library()),model());
  3. setsize(path1,3,1,1);
  4. setsize(path2,8,1,1);
  5. setloc(path1,1,0,0);
  6. setloc(path2,5,1,0);
  7. setrot(path2,0,0,90);
  8. function_s(path1, "finalizeSpatialChanges");
  9. function_s(path2, "finalizeSpatialChanges");
  10. treenode from = path1;
  11. treenode to = path2;
  12. if (isclasstype(from, "AGV::Path") && isclasstype(to, "AGV::Path")) {
  13. double distAlongFrom = 2.5;
  14. double distAlongTo = 0.16;
  15. treenode newPath = applicationcommand("Path_joinTo", from, to, distAlongFrom, distAlongTo);
  16. }
5 |100000

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