question

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

Creating a static FlexScript class

Hi,

I am looking to create a static FlexScript class, basically an enumeration with some static int fields, without necessarily having a SDT behind it.

I think the AGV.BodyOffset.TrainTrailingEdge class is a perfect example. Would you be able to share how to define this in C++?

1700051921975.png

Thanks!

FlexSim 24.0.0 beta
flexscriptdot syntaxstatic
1700051921975.png (17.9 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
1 Like"
Jordan Johnson answered Mischa Spelt commented

Check out the AStarDirection class in AStarTypes.h/cpp:

https://github.com/flexsim/AStar/blob/master/AStarDLL/AStarTypes.h

https://github.com/flexsim/AStar/blob/master/AStarDLL/AStarTypes.cpp

The main steps are:

  1. Declare a C++ enum (in this example, Direction)
  2. Declare a class with a bindInterface() methde (in this example, AStarDirection)
  3. Fill out bindInterface() with static int properties
  4. In the bindInterface() of an SDT, call bindClass() on your class

Usually, a module will define at least one odt/sdt FlexScript interface. So you can call bindClass() in the other class' bindInterface(). If you don't have an SDT class, you'll need to make one. It's okay if that binding class has no methods or properties. In 24.0, you can set the bind flags of the currently binding class, so you can make the currently binding class not user accessible, so it won't appear in any autocomplete.

· 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 ·
I did not know about that repository, very useful, thanks!
0 Likes 0 ·