Scripting

 From:  Michael Gibson
7238.17 In reply to 7238.15 
Hi dune1982,

> What does the 0 stand for?

It's the index number for which specific factory input to set.

Geometry factories can have various different inputs in them, they are in a list and when you call factory.setInput() that number tells it which of the different inputs you want to set for this particular call.


> Does the network always take the first three objekts in the list?

It uses whatever objects are put in the list - if it has 3 objects in the list it will use those 3 objects. If you have 11 objects in the list it will use those 11 objects.


> Is there a way to empty the list so it is not necessary to recreate it?

Creating a list is not an expensive operations so there is no need to worry about avoiding creating one. The easiest way to get an empty list is to make a new one - you can remove objects from an object list by calling list.removeObject(obj); but you would need to loop through the object list and call this on each object in order to do it that way.


> Last question what exactly does factory.commit(); do?

First it calls factory.update() automatically if it has not been called previously. factory.update() creates the new object and puts it in the geometryDatabase so that it can be seen. Also factory.update() deals with hiding any input objects if the factory is one that removes some existing object (like for example Transform > Move removes the original object being moved and creates a new moved object). If the command ends without factory.commit() being called these changes are reverted, with the newly added objects removed and the objects to be removed shown again. When you call factory.commit() it finalizes the factory's action and actually deletes the objects to be removed and will keep the newly created objects.

With a normal command, as you adjust various options factory.update() will be called so you can see the result on screen. Then at the end when the command is finished it called factory.commit() to make the last update stick. If the command is canceled in any way without .commit() ever being called any changes it made are reverted.


> Can't I let the network command create the three networks and then do the factory.commit(); at the end to only update the ui once?

No, not with the regular factory.update() and factory.commit() mechanism, because that mechanism is oriented around the workflow of the regular Network command and there is no way in the regular Network command to build 3 networks in one shot.

But instead of calling update() and commit(), it is possible to use a different mechanism which is called factory.calculate() - if you call factory.calculate() it will return an object list of what the factory generates but it does not automatically put it in the geometry database like update/commit does, so you can then batch up the results and then call moi.geometryDatabase.addObjects( objectlist ); to add them in one shot.

- Michael