question

Martin K5 avatar image
0 Likes"
Martin K5 asked Martin K5 commented

Is it possible to set up a label by code?

Hi,

I would like to ask, if it is possible to set up a label by code? For example I'll find and object of rack and I want to assign a label.

Thank you.

Martin

FlexSim 21.1.4
labelscode
· 1
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 Martin K5 commented

The easiest way to add a new label on an object is by setting the value of a new dynamic label. This code will make sure the object has a MyLabel label and will set its value to 5.

  1. object.MyLabel = 5;

Another way is to use the labels.assert() method. This code will make sure the object has a MyLabel label, and if it does not it will set the initital value to 5, otherwise it does nothing.

  1. object.labels.assert("MyLabel", 5);
· 1
5 |100000

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