question

niko J2 avatar image
0 Likes"
niko J2 asked Phil BoBo commented

How to change direction of Conveyor Drawing function_s

Hello,

i would like to automatize Conveyor building via CAD Data.

Straight conveyor are working pretty well.

My CAD data for curved conveyor are like:

startpoint (1), endpoint (2) & mid of circle (3).

im using these commands

function_s(newConveyor, "dragStart", xKoordSt, yKoordSt, zKoordSt, activedocumentview());

function_s(newConveyor, "dragEnd", xKoordEn, yKoordEn, zKoordEn, activedocumentview());

how to change direction of conveor (green line)

Choose One
conveyorsautobuildconveyor moduleconveyor properties
o582d.png (81.0 KiB)
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
1 Like"
Phil BoBo answered Phil BoBo commented

Rather than using dragStart and dragEnd function_s commands, you can set the values of the curved conveyor directly, such as the code below.

A curved conveyor is specified in FlexSim via the location (mid of circle), start angle, sweep angle, and radius.

  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.  
  6. treenode LibraryCurvedConveyor = node("?CurvedConveyor", library());
  7. for(int j = 1; j <= arcs.numRows; j++)
  8. {
  9. int startIndex = arcs[j][1] + 1;
  10. double x1 = vertexLocations[startIndex][1];
  11. double y1 = vertexLocations[startIndex][2];
  12. double z1 = vertexLocations[startIndex][3];
  13. int endIndex = arcs[j][2] + 1;
  14. double x2 = vertexLocations[endIndex][1];
  15. double y2 = vertexLocations[endIndex][2];
  16. double z2 = vertexLocations[endIndex][3];
  17. int centerIndex = arcs[j][3] + 1;
  18. double x3 = vertexLocations[centerIndex][1];
  19. double y3 = vertexLocations[centerIndex][2];
  20. double z3 = vertexLocations[centerIndex][3];
  21. double StartAngle = Math.degrees(arcs[j][4]);
  22. double EndAngle = Math.degrees(arcs[j][5]);
  23. double SweepAngle = EndAngle - StartAngle;
  24. if (SweepAngle < 0) {
  25. SweepAngle += 360;
  26. }
  27.  
  28. Conveyor curved_conveyor = createinstance(LibraryCurvedConveyor, model());
  29. curved_conveyor.setLocation(x3,y3,z3);
  30. double dx = x3 - x1;
  31. double dy = y3 - y1;
  32. double dz = z3 - z1;
  33. double radius = sqrt(dx*dx + dy*dy);
  34. setvarnum(curved_conveyor, "rise", dz);
  35. setvarnum(curved_conveyor, "startAngle", StartAngle);
  36. setvarnum(curved_conveyor, "sweepAngle", SweepAngle);
  37. setvarnum(curved_conveyor, "radius", radius);
  38.  
  39. function_s(curved_conveyor,"finalizeSpatialChanges");
  40. }
· 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.