Problem scripting a 'trim' operation

 From:  Dave Morrill (DMORRILL)
3541.8 In reply to 3541.2 
Michael,

Thanks for the detailed explanation of the factory execution model! I hope you don't mind if I use bits and pieces of your explanation in the API documentation I am writing?

For the most part, it sounds like the mental model I had developed in the course of reading through a lot of the MoI command scripts was more or less correct, but having it spelled out is really very helpful. The bit about the binders automatically calling 'update' helps clarify how the binders operate quite a bit, since deducing how they worked just from the Javascript code examples was quite a bit of guesswork on my part (although it turns out the actual function as you described it is nearly identical to the mechanism I use in the Python Traits framework I wrote that I'm using to do a lot of the external scripting of MoI with).

Now, just to nail this thing down a little better, let me summarize what I think I understand about MoI geometry and its life cycle:

- In order to be displayed on the screen, all geometry must be in the geometry database.
- It is possible to create, maintain and use geometry that is not displayed to the user (i.e. not in the geometry database).
- Factories can work with any geometry objects, whether or not they are in the geometry database.

Now, the big question: when/how are geometry objects destroyed?

Since C++ does not do automatic garbage collection, my guess is that you are using some form of reference counting, probably based upon the geometry objects being added to/removed from ObjectList objects. Based upon this assumption, adding geometry to the geometry database automatically keeps geometry alive, because it become part of one or more lists that the database manages. Sub-objects are kept alive by lists maintained by parent objects. Geometry that is not in the database is kept alive by being part of one or more ObjectLists maintained outside of the database.

Destruction of geometry not in the database can be accomplished by the removal of the geometry objects from all ObjectLists being maintained by a script (talking from a scripting perspective).

If you can confirm or clarify this description, I think it will go a long way towards helping me to understand the MoI internals better...

- Dave Morrill