Create a Subnode in onPreDraw When Using Kinematics

Create a Subnode in onPreDraw When Using Kinematics

nilP8GEZ
Observer Observer
6 Views
1 Reply
Message 1 of 2

Create a Subnode in onPreDraw When Using Kinematics

nilP8GEZ
Observer
Observer

[ FlexSim 23.2.2 ]

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!!!

Accepted solutions (1)
7 Views
1 Reply
Reply (1)
Message 2 of 2

JordanLJohnson
Autodesk
Autodesk
Accepted solution

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.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes