question

俊亦 avatar image
0 Likes"
俊亦 asked Jason Lightfoot edited

how to find (reference) Token in script?

I want to write a script, the goal is to find a Token object (has been created) in the model, then transfer its length to string, and return it, how can I do.

FlexSim 20.1.0
flexsim 20.1.0scripttoken
· 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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

If you have a token for each box/item then you can create a pointer to the token that created it (or was created by an item event). For example in the Create Objects activity you can add the pointer like this:

Using the pointer you can then get the unique id from the item reference using:

  1. Token mytoken=item.token;
  2. int myid=mytoken.id

or

  1. item.token.as(Token).id


This way the token has a label 'item' and the item has a label 'token' so they can find each other without you having to search through all the tokens.





· 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.