question

Edmilson Ml avatar image
0 Likes"
Edmilson Ml asked Edmilson Ml edited

how can i change shape dimensions by custom code

Good Morning!


I need help, I'm using custom code to change the 3D shape of an AGV, so I imported the 3D model via the media files option (view > media files) and used the "setobjectshapeindex (token.resource, 95) function ); "however I have a problem, when using custom code the 3D object is MUCH bigger.

below I have attached an example of 2 AGV with modified shape.

the TaskExecuter1 manually modified in visuals,

TaskExecuter2 modified by custom code.

How can I solve this? and how can i change shape dimensions by custom code?salve1.pngMODEL.fsm


FlexSim 21.2.2
custom code
salve1.png (46.1 KiB)
model.fsm (5.1 MiB)
5 |100000

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

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Phil BoBo edited

Your custom code is just setting the shape index. Unless your new shape has the exact same shape factors as the previous shape, then it isn't going to draw the same.

Rather than just setting the shape index, you should use the Change Visual activity to set the shape, which will apply the shape factors of the new shape in order to fit it into the yellow box.

1631716597392.png

If you want the activity to also adjust the size of the object (which is what happens when you select a 3D shape through Properties), then you can remove the setsize() command on line 23 of the Change 3D Shape pick option. The applyshapefactors() command adjusts the size of the object to be the size specified in the 3D shape file. That setsize() command adjusts it back to the original size of the flowitem.


1631716597392.png (94.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.

Rodrigo F2 avatar image
0 Likes"
Rodrigo F2 answered

When placing the Custom Code activity, be sure to select: Visual>Change 3D Shape; so that you can modify the object by custom code as required.

imagen.png

In my case, I needed to add an "Assing Label" and named it "truck", and referenced it using the sampler in 3D.

Even after performing this process, it was still necessary to resize the object by removing the setsize(), because when the model is reset, it resizes itself to the original values of the original object.

My model: model (1).fsm


imagen.png (21.2 KiB)
model-1.fsm (5.1 MiB)
5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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