question

Hitesha N2 avatar image
0 Likes"
Hitesha N2 asked Phil BoBo commented

How to autobuild conveyor's as per layout with auto-connection between them?

FlexSim 18.2.2
autobuildconveyor moduleautoconnect
· 2
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
3 Likes"
Phil BoBo answered Phil BoBo commented

Use createinstance() to create the conveyor. See: Create a straight conveyor in code?

Use function_s(conveyor,"finalizeSpatialChanges") to update the automatic connections to nearby conveyors. See: Create conveyor system in code

Check the Load Snap Points box in the Background Drawing Wizard to load the AutoCAD data into the tree in a format that you can read with code. See How are snap points used?

Access that data using the Table FlexScript API. For example:

  1. Object dwg = Model.find("FlexsimModelBackground");
  2. Table vertexLocations = getvarnode(dwg, "snapPoints").subnodes["Vertex Locations"];
  3. Table lines = getvarnode(dwg, "snapPoints").subnodes["Lines"];
  4. Table arcs = getvarnode(dwg, "snapPoints").subnodes["Arcs"];
  5. Table circles = getvarnode(dwg, "snapPoints").subnodes["Circles"];
  6.  
  7.  
  8. treenode LibraryStraightConveyor = node("?StraightConveyor", library());
  9. for (int i = 1; i <= lines.numRows; i++) {
  10. int index1 = lines[i][1] + 1;
  11. double x1 = vertexLocations[index1][1];
  12. double y1 = vertexLocations[index1][2];
  13. double z1 = vertexLocations[index1][3];
  14. int index2 = lines[i][2] + 1;
  15. double x2 = vertexLocations[index2][1];
  16. double y2 = vertexLocations[index2][2];
  17. double z2 = vertexLocations[index2][3];
  18. Conveyor conveyor = createinstance(LibraryStraightConveyor, model());
  19. conveyor.setLocation(x1, y1, z1);
  20. double dx = x2 - x1;
  21. double dy = y2 - y1;
  22. double dz = z2 - z1;
  23. double length = sqrt(dx*dx + dy*dy);
  24. conveyor.size.x = length;
  25. conveyor.rotation.z = Math.degrees(Math.atan2(dy, dx));
  26. setvarnum(conveyor, "rise", dz);
  27.  
  28. function_s(conveyor, "finalizeSpatialChanges");
  29. }
· 7
5 |100000

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