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.
/**Custom Code*/ Model.find("AGVNetwork").subnodes.clear(); int length = 5; int width = 5; List CPoints = List("ControlPoints"); //vertical lines for (int i = 0; i <= width; i++){ treenode path = createinstance(node("/AGV/StraightPath",library()),model()); setloc(path,i*725.2+362.6,362.6,0); setrot(path, 0,0,90); setsize(path, 725.2*length,1,1); getvarnode(path, "isTwoWay").value = 1; function_s(path, "finalizeSpatialChanges"); } //horizontal lines for (int i = 0; i <= length; i++){ treenode path = createinstance(node("/AGV/StraightPath",library()),model()); setloc(path,362.6,i*725.2+362.6,0); setsize(path, 725.2*width,1,1); getvarnode(path, "isTwoWay").value = 1; function_s(path, "finalizeSpatialChanges"); } for (int i = 0; i <= length; i++){ for (int j = 0; j <= length; j++){ treenode controlpoint = createinstance(node("AGV/ControlPoint", library()), model()); setloc(controlpoint,i*725.2+362.6,j*725.2+362.6,0); CPoints.push(controlpoint.value); } }
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!