Bind NodeListArray from within SDT class

thomas_smithWKC4J
Enthusiast Enthusiast
0 Views
3 Replies
Message 1 of 4

Bind NodeListArray from within SDT class

thomas_smithWKC4J
Enthusiast
Enthusiast

[ FlexSim 23.0.1 ]

I can't figure out how to bind a NodeListArray for an SDT derivative.

For ODT, this is how I would do it for a list of SDTs:

class MyODTType: public ObjectDataType
{
   NodeListArray<MySDTType>::SdtSubNodeBindingType mylistofSDTs;
   
   void MyODTType::bindVariables() 
   {
      ObjectDataType::bindVariables();
      bindVariable(variable); // <---
   }
};

My SDTs also need to have a list of treenodes within them. Which bind macro do I use in this example?

class MySDTType: public SimpleDataType
{
   NodeListArray<treenode>::NodePtrType mylistofnodes;
   
   void MySDTType::bind() 
   { 
      SimpleDataType::bind();
      // What goes here? 
      // I have tried with no success:
      // bindNodeListArrayAsClass(treenode, mylistofnodes);
   }
};
0 Likes
Accepted solutions (1)
1 View
3 Replies
Replies (3)
Message 2 of 4

jordan_johnsonPM57V
Autodesk
Autodesk
Accepted solution

To bind a NodeListArray variable in a SimpleDataType, use bindSubNode:

bindSubNode(someNodeListArray, 0)

Basically, since the NodeListArray needs a parent node to place all its list elements under, it can be treated as a node in bindSubNode().

The bindClass() methods/macros deal with adding a new FlexScript API class, rather than binding member variables of a class. For more information, see:

https://docs.flexsim.com/en/23.0/Reference/DeveloperAdvancedUser/ModuleSDK/ExtendingFlexScript/Exten...

There is an example module file available on that page you might find helpful.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 4

thomas_smithWKC4J
Enthusiast
Enthusiast

Hi Jordan. This works for binding the NodeListArray, but when I try to add elements to it I am getting an exception.

NodeListArray<treenode>::NodePtrType mylistofnodes;
...
bindSubNode(mylistofnodes, 0);
...
mylistofnodes.add(mytreenode); // <--- here

Could be an issue happening elsewhere in my code, but I believe I have isolated it here. I'll investigate, but do you have any ideas on what could be causing this? There error I'm getting is just a generic exception in processeventinlist.

0 Likes
Message 4 of 4

thomas_smithWKC4J
Enthusiast
Enthusiast
Nevermind, I figured it out. I was creating an instance of my SDT, then adding to its NodeListArray, then adding to the tree.

I fixed it by creating the instance, immediately adding it to the tree, and then manipulating the NodeListArray.

Thanks again for your help.

0 Likes