question

Stan Davis avatar image
0 Likes"
Stan Davis asked Stan Davis commented

Determine currently acquired resources

What is the preferred method of determining whether a token has acquired a shared resource or not?

In custom code, I need to determine if a given token has acquired certain resources. I currently test whether the node name returns 'NULL' or not. This works but seems inefficient...

if (getname(getlabel(token,"myresource")) == "NULL") { // do something }

Thanks,

Stan

FlexSim 16.2.0
process flowacquire resource
5 |100000

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

Matt Long avatar image
0 Likes"
Matt Long answered Stan Davis commented

If the label exists when you have acquired the resource and doesn't exist if you haven't, then the following two lines would return true if the resource has been acquired.

getlabel(token, "myresource") != nullvar
or
objectexists(label(token, "myresource"))
· 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.

Stan Davis avatar image Stan Davis commented ·

Thanks Matt.

0 Likes 0 ·
Steven Hamoen avatar image
0 Likes"
Steven Hamoen answered Stan Davis commented

@Stan Davis If your resource is a 3D object you can use objectexists()

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

Stan Davis avatar image Stan Davis commented ·

Thanks Steven

0 Likes 0 ·