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.

Conveyor conveyor = Model.find("Conveyor1");
Color newColor = Color.green;

treenode visualization = conveyor.getProperty("ConveyorVisualization");
treenode visColor = visualization.find("drawColor");
visColor.subnodes[1].value = newColor.r;
visColor.subnodes[2].value = newColor.g;
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.

anthony.johnson avatar image anthony.johnson ♦♦ commented ·

For the next version (21.1) we have added the ability for the visualization to use the individual conveyor's color for the side skirt, belt, and rollers of the conveyor. Hopefully this should allow you to do what you need.

1 Like 1 ·
Beatriz Spaggiari avatar image Beatriz Spaggiari commented ·

I tried to use this and just changed the color of the sides of the conveyor, how can I change the color of the texture also by the codes?


0 Likes 0 ·
1611926971581.png (202.4 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ Beatriz Spaggiari commented ·
treenode beltColor = visualization.find("beltColor");
1 Like 1 ·
Beatriz Spaggiari avatar image Beatriz Spaggiari commented ·

Thanks for the suggestions. I used the suggested commands and managed to color the conveyors by codes. But now a new problem has arisen. As I used the same type of visualization for all the conveyors, when coloring one, all the other conveyors are painted the same color, but this process should be done individually for each conveyors, according to its specific state.

How can I paint a conveyors individually, via codes, without having to assign a different type of visualization to each one? Since, I have thousands of conveyors in the process. As in FlexSim 2019/2020, where the color of the custom converyor was a local property.

0 Likes 0 ·