question

Nil Ns avatar image
2 Likes"
Nil Ns asked Jordan Johnson answered

Create a Subnode in onPreDraw When Using Kinematics

Heyy.

When I try to create a kinematics through ProcessFlow, using the CreateKinematics, I notice that in addition to creating this, a subnode is created within onPreDrawTrigger in the object.

1700668850018.png


If I try to create the kinematics by code, this does not happen. Adding a code in onPreDraw with updateKinematics fixes it, but would there be a way to create this subnode by code so that it looks cleaner and it is not obvious that this trigger exists?

Thank you!!!

FlexSim 23.2.2
kinematicstreenodeonpredraw
1700668850018.png (31.0 KiB)
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

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered

Short answer: not without C++. Adding the pre-draw trigger and calling updatekinematics() is the right way to go.

Long answer: With a C++ module dll, you can do what Process Flow does:

  1. Create a class that extends FlexSimEvent
  2. Override the execute() method to call update kinematics
  3. Assert the onPreDrawTrigger:
    treenode eventNode = myODT->assertEvent("OnPreDraw")
  4. Switch it as an active listener:
    switch_activelisteners(eventNode, 1)
  5. Add a subnode to the event node. Add your custom Event class to it. Couple it to another node somewhere.

Technically, you can assert the event in FlexScript like so:

function_s(myObject, "assertEvent", "OnPreDraw");

And maybe you could find a way to copy/paste the kinematics nodes somewhere and then couple them correctly. But it would be hard to get right.

5 |100000

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