question

Allyson avatar image
0 Likes"
Allyson asked Jason Lightfoot edited

How to check whether a treenode pointer reference is an object or a flowitem?

I have a model where I have messages being sent to a FR object, where the message sender is either a flowitem or another FR object. The FlexScript code that is triggered by the message will need to have two different execution paths depending on whether the sender is a flowitem or an object. Is there a way to know this? I know of the isclasstype() command, but I'm not sure if it's possible to use this command to check for reference to a flowitem (since flowitems don't have a class attribute node). I'm assuming not. If not, I'm not sure what I can use.

I'm doing this in FlexScript so I'm looking for the specific command reference if possible.

Thanks in advance!

FlexSim 23.1.0
flexscriptitemobjecttypeclass
· 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.

Mischa Spelt avatar image Mischa Spelt commented ·

If the message has two different execution paths depending on the sender, isn't it better to send two different messages altogether? Presumably where you send the message you do know if it's a flow item or a FR?

0 Likes 0 ·

1 Answer

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

The correct way to test for a flowitem is to check the existence of the 'itemtype' node.

objectexists(itemtype(object))

Since taskexecuter flow items have a class node, testing for the class alone isn't strictly enough.


If you do want to test for an object being classless you can use:

object.getProperty("Class")==NULL;
· 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.

Allyson avatar image Allyson commented ·

Thank you! I knew that the flowitems didn't have a class attribute node but I can't believe I didn't think to exploit that fact to achieve what I needed. Very clever solution, bravo. Appreciate the help!

0 Likes 0 ·