question

Nil Ns avatar image
0 Likes"
Nil Ns asked Phil BoBo answered

Build a C+++ node on eventFunctions in Library

Hello,

I am trying to modify an EventFunction to alter the VideoRecorder.I noticed that the object created in the model doesn't have event functions, so I suppose they use the class functions (like inheritance in C++ classes).

The thing is, I am not able to compile that code. I try to delete all the text or make some changes, and I don’t know how to compile and make FlexSim execute that code on onMessage.

1737987491682.png

In some cases, I don't know how, but I manage to do it. However, I think that I compile it as FlexScript, and then it returns an error.

I try to build the node in FlexSim, toggle the node to C++, and return to C++. I try the "make all code" buttons on the toolbar, but it doesn't seem to take effect. If this node exists and is a C++ node, the original code is executed, even if I remove all the text.

I have been trying to use the SDK module to modify it, but I haven't managed to achieve anything.

I don’t think it is necessary to destroy the VideoRecorder object in the model and recreate it to make the changes take effect, but I tried it, and it didn’t work either.

What can I do to compile that code and make it work?

FlexSim 24.2.3
c++librarybuild node
1737987491682.png (50.6 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

Phil BoBo avatar image
0 Likes"
Phil BoBo answered

We no longer support directly compiling C++ nodes in the MAIN tree. All the C++ nodes you see in the tree are compiled into C:\Program Files\FlexSim\program\flexsimcontent.dll. You can't simply change those nodes. They exist for historical reasons, as described in:

https://docs.flexsim.com/en/25.0/Reference/DeveloperAdvancedUser/ModuleSDK/ModuleDevelopment/ModuleDevelopment.html#background

If you want to modify the MAIN tree, you should use the Module SDK, and you shouldn't change C++ nodes.

FlexScript and C++ are not interchangeable. That code is C++. It contains syntax and functions not available in FlexScript. You cannot simply change that node to FlexScript. It won't compile.

If you want to override the VideoRecorder's OnMessage eventfunction, you may be able to add a FlexScript OnMessage eventfunction to the VideoRecorder instance in the MODEL tree and use inheritcode() to call the C++ library class eventfunction from your overridden FlexScript instance eventfunction.

5 |100000

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