question

Jouky D avatar image
1 Like"
Jouky D asked Julie Weller commented

How to customize the meshes in the selected 3D shape with FlexScript?

Hello everyone,

I want to change by code the color of Mesh of a Shape. Normally I go to More Visuals (of the Object) and then I press the button of Customize the meshes in the selected 3D shape. After that I select a Mesh and I check Override to change the Diffuse Color. Is there a way to change the color of the mesh I want (from the object) in FlexScript?

1687855609002.png
Thank you!

FlexSim 23.1.2
3d shapemeshmore visuals
1687855609002.png (7.5 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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Julie Weller commented

Any information that is unique to an object should be located in its attribute tree. If you compare a default object to one that had these values changed, you will find that making changes in the menu from your screenshot adds the following node structure to the visuals attribute subnode.

1687864870019.png

If you copy these nodes to a different object, it will use the same settings (remember to adjust the value of the shapedata node to point to the correct subnode).

And with the knowledge of where the information is stored, you can change it in code.

  1. // Change the diffuse color
  2. setsdtvalue(Model.find("BasicFR1>visual/localshapedata/1/block"), "diffuseColor", [0.6, 0.2, 0.8, 1]);

1687864870019.png (6.1 KiB)
· 8
5 |100000

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