question

Kevin A2 avatar image
0 Likes"
Kevin A2 asked Phil BoBo answered

Question on module

After developed a module, when I open FlexSim (before opening a model), the compiler console shows some Flexscript errors. This is because in an edited node of my module I referred to some objects of a model, which FlexSim sees them as "Undefined" when I am not opening the model. Is there a way to make FlexSim not to "read" the module until I open a model, so that these errors won't pop out when I first open FlexSim?

And here is an unrelated question: I want to clear up the output console everytime I press the reset model button, how can I do that? Thank you very much.

FlexSim 17.2.5
module sdkmodules
· 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 ·

There is a Model Open trigger that you can attach your own logic to by creating subnodes (and storing those in the module).

Also you may want to make sure that the code that gets executed is programmed defensively, e.g. checking if the objects exist first and exiting with a return -1 when they don't.

0 Likes 0 ·

1 Answer

Phil BoBo avatar image
1 Like"
Phil BoBo answered

Don't reference model objects from a module. Modules customize the application. They aren't model-specific. If you want to read a value from within a model, you need to assert it with a default value. You can't assume that the object is there.

In the toolbox, add Modeling Logic > Model Trigger > On Reset with the following code to clear the output console:

clearconsole();
5 |100000

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