Add OnDestroy to planes and task executors

Add OnDestroy to planes and task executors

guiroehe
Collaborator Collaborator
89 Views
4 Replies
Message 1 of 5

Add OnDestroy to planes and task executors

guiroehe
Collaborator
Collaborator

[ FlexSim 25.0.2 ]

Hello,

please see the attached example. Despite OnDestroy events have been added to all objects, when a plane is deleted, only the one added to the shape is executed. Is there a proper way to add OnDestroy events to the other objects, please?

OnDestroyExample.fsm

Thank you.

0 Likes
Accepted solutions (1)
90 Views
4 Replies
Replies (4)
Message 2 of 5

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

In your OnDestroy code you can add:

forobjectlayerunder(c)
     nodefunction(OnDestroy(a));

I'm curious why you need this though - group lists should automatically get updated when destroying objects which may provide some features you're looking for.

You can also create couplings to the objects under a container/folder node such that it effectively contains a list of object pointers - these are removed when the other end of the coupling is destroyed - keeping your list correct. This is how connections are maintained in the base objects and is a technique employed in numerous areas (e.g. process flow membership)

0 Likes
Message 3 of 5

guiroehe
Collaborator
Collaborator
Hi, @Jason Lightfoot ,

if the purpose of a container is to represent a 3D object which combines multiple objects, it could make more sense: the container has labels, so it would be expected that their initial and final states could be controlled by the container itself. This actually extends to the "onresettrigger".

One can, of course, create all logic on the triggers of one of the embedded objects, but it is just not natural, and violates the OO concept of encapsulation, for those that still like that paradigm.

In the example I sent before, the overall idea is to be able to remove a group if it is empty. As the groups are named based on labels provided by the user (e.g., a team's name), removing empty groups becomes good housekeeping and reduces effort for debugging.

I hope I could explain better why my suggestion was made.

Thank you.


0 Likes
Message 4 of 5

jason_lightfootVL7B4
Autodesk
Autodesk
I think we need to look at what you're trying to accomplish and start talking about specifics. I agree there are a number of non-OO compliant aspects of the user experience of FlexSim, but we usually are able to get the behaviours we want and often in a way that has good structure that can be both generic and managed.
0 Likes
Message 5 of 5

guiroehe
Collaborator
Collaborator
Hi, @Jason Lightfoot , thank you.

The expectation is that each embedded object should take are of their own initialization and destroying procedures. Again, it is just modularity and encapsulation. Having to call explicitly the destroy for embedded/underlayer objects might give the impression of "savig time" when the call is not needed, but in fact the impact on performance is almost neglectable, even in C# based environments. It also makes the code unnecessarily convoluted, as either the parent object has to deal with the "garbage" of the underlayer objects, or the behaviors are not the expected from an OO environment.

Anyway, I now know (as it is not explicit in the help/manual) the I have to manually handle that.

Thank you for your interest!

0 Likes