question

lariwalker avatar image
0 Likes"
lariwalker asked lariwalker commented

How do I add code-generated control points to code-generated AGV paths?

Hi,

I'm using code to draw a grid of AGV paths, with control points at each intersection. The problem is when I add a control point in position, it doesn't "snap" onto the path as expected.


  1. /**Custom Code*/
  2.  
  3. Model.find("AGVNetwork").subnodes.clear();
  4.  
  5. int length = 5;
  6. int width = 5;
  7. List CPoints = List("ControlPoints");
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. //vertical lines
  15.  
  16. for (int i = 0; i <= width; i++){
  17. treenode path = createinstance(node("/AGV/StraightPath",library()),model());
  18. setloc(path,i*725.2+362.6,362.6,0);
  19. setrot(path, 0,0,90);
  20. setsize(path, 725.2*length,1,1);
  21. getvarnode(path, "isTwoWay").value = 1;
  22. function_s(path, "finalizeSpatialChanges");
  23.  
  24. }
  25.  
  26. //horizontal lines
  27.  
  28. for (int i = 0; i <= length; i++){
  29. treenode path = createinstance(node("/AGV/StraightPath",library()),model());
  30. setloc(path,362.6,i*725.2+362.6,0);
  31. setsize(path, 725.2*width,1,1);
  32. getvarnode(path, "isTwoWay").value = 1;
  33. function_s(path, "finalizeSpatialChanges");
  34. }
  35.  
  36. for (int i = 0; i <= length; i++){
  37. for (int j = 0; j <= length; j++){
  38. treenode controlpoint = createinstance(node("AGV/ControlPoint", library()), model());
  39. setloc(controlpoint,i*725.2+362.6,j*725.2+362.6,0);
  40. CPoints.push(controlpoint.value);
  41. }
  42. }


Also, I'd like to write a code to delete all control points at the start. How could I write some code that finds all "controlpoint" objects and deletes them?

Thanks!

FlexSim 22.2.3
agvcodecontrol points
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

Patrick Zweekhorst avatar image
0 Likes"
Patrick Zweekhorst answered lariwalker commented

Hi @LariWalker ,

You could use some code that looks like the code below:

  1. Array cps = [];
  2. forobjecttreeunder( model() )
  3. {
  4.     if( isclasstype( a, "AGV::ControlPoint" ) )
  5.     {
  6.         cps.push( a );
  7.     }
  8. }
  9.  
  10.  
  11. for( int i = 1; i <= cps.length; i++ )
  12. {
  13.     Object cp = cps[ i ];
  14.     cp.destroy();
  15. }

Hope this helps you further

· 4
5 |100000

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