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.

Jeff Nordgren avatar image Jeff Nordgren commented ·

Hi @laijunyi1996,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

Proprietary models can be posted as a private question visible only to FlexSim U.S. support staff. You can also contact your local FlexSim distributor for phone or email help.

Thanks.

0 Likes 0 ·
俊亦 avatar image 俊亦 Jeff Nordgren commented ·

I hope my model works like this

queue1: inventory

queue2: waiting line

branch: generate demand(random number of box)

first, operator1 take 10 groups of boxes from queue1 into queue2, then flexsim send the demand quantities of each branch to python , then python calculate the best transport route (VRP problem), the drivers transport box along given route.


so I want to achieve that flexsim can collect the quantites of each demand , then spell them in to a string, then send it to python. this requires that flexsim locates these tokens (GroupOfItems1234), return its quantites in script.

ask_for_help.fsm

0 Likes 0 ·
ask-for-help.fsm (69.9 KiB)

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:

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

or

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.

俊亦 avatar image 俊亦 commented ·

thank you , this help me a lot.

0 Likes 0 ·

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.