question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Mischa Spelt commented

How to implement C++ toggled node?

Hi,
Are there any pointers on how to create a C++-toggled node that will execute a member function on a module object? I wanted to 'override' an eventfunction which is called through function_s so I created a C++ toggled node with contents

c->asObject(MyClassName)->MyMethodName(); 

but though FlexSim did not complain it did not call any C++ code either. I tried toggling the node as regular FlexScript and putting in a msg() to make sure it does get called. Any tips?

FlexSim 18.1.2
c++
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

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Mischa Spelt commented

Try

o(MyClassName,c).MyMethodName();

Also, if you are trying to call a method on a class defined in your module DLL, you should probably toggle the node as DLL and put it in your DLL instead of C++ compiled into flexsimcontent.dll.

Also, from a C++ toggled node, your MyClassName might be ModuleName::MyClassName because the code isn't in your module's namespace.


eventfunctions.png (215.9 KiB)
· 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 ·

Thanks Phil, I was hoping to bind directly to my class method, but I guess a global function coupled to a DLL-toggled node is still the way to go.

0 Likes 0 ·