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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Martin K5, was Matthew Gillespie's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

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.

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.

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.

Martin K5 avatar image Martin K5 commented ·

Hi,

thanks a lot, it works exactly how I wanted.

Martin


0 Likes 0 ·