question

Beatriz Spaggiari avatar image
0 Likes"
Beatriz Spaggiari asked Beatriz Spaggiari commented

Code to change colors of Conveyors in FlexSim 2021

In FlexSim 2020, I had this code to change the colors of a conveyors:

Object objeto = model().find("/"+nome_objeto);
treenode color_node = node(">variables/localType/drawColor", objeto);
Array cor = [0,255,0];

setnodenum(rank(color_node, 1), cor[1]);
setnodenum(rank(color_node, 2), cor[2]);
setnodenum(rank(color_node, 3), cor[3]);

How can I do this action in FlexSim 2021, since during the process of upgrading from version 2020 to version 2021, many conveyors in my process no longer have the node ">variables/localType/drawColor", for unknown reasons.

FlexSim 21.0.2
conveyorsflexsim 21.0.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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Beatriz Spaggiari commented

Conveyor types were removed in 21.0. However, conveyors still have visualizations that can be shared between multiple conveyors. So you need to get the conveyor's visualization and then set the color on the visualization object.

  1. Conveyor conveyor = Model.find("Conveyor1");
  2. Color newColor = Color.green;
  3.  
  4. treenode visualization = conveyor.getProperty("ConveyorVisualization");
  5. treenode visColor = visualization.find("drawColor");
  6. visColor.subnodes[1].value = newColor.r;
  7. visColor.subnodes[2].value = newColor.g;
  8. visColor.subnodes[3].value = newColor.b;
· 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.