Hi Dave, first a quick description of how calculate / update / commit / cancel is supposed to work.
The factory system is set up primarily to support interactive commands where the user may be changing parameters interactively and wanting to see some feedback on the screen while the command is running.
In order to show an object changing, what actually happens is the existing object is hidden (but still in the geometry database), then the edited object is created by the factory, and added to the geometry database so that it will render on the screen when the geometry database is drawn, because that's how all things are drawn, by drawing the geometry database. This happens during calls to .update(), which can be called either directly by a command script, or if the is a binding set up the binding mechanism will automatically call update when the other partner of the bind is triggered. So for example when UI control is bound to a factory input, when the UI control changes it will stuff the new value into the factory and call update(), that's what the binders handle.
But the original objects, and newly created objects are kept track of by the factory in some internal lists. If the factory is canceled (which can happen by the command script itself calling .cancel() or also by the system if the factory is forcibly pulled down), then it restores the original objects visibility and removes the new objects from the geometry database.
During the command ending cleanup step, any active factories that have not had .commit() called on them are also canceled.
So in order to signal that the command script was fully executed, it calls .commit() before it ends to signal that the command's whole process was executed, and at that point the original objects (that up until now were just hidden) are actually removed from the database.
Some commands also have what are called "UI objects" that are things like additional lines or points added to the geometry database while the command is running for additional illustration purposes.
The .calculate() method is added to this factory system to help with someone who wants to use the factory procedurally in a script rather than in an interactive command. It runs the factory and generates the new objects, but the new objects are not automatically added to the geometry database, they are just returned in a list so they could be used for additional calculations without necessarily showing up on the screen, and the original objects are not hidden.
During .calculate() there is a flag set to disable the creation of "UI geometry" by the factory, but possibly some older commands need to be updated to respect that. If you are seeing some left-over bits of lines or points or stuff like that, let me know what commands you see them in and they probably need to be updated to not generate UI geometry when the flag is set.
So I hope that description helps a bit at least, I'll take a look at Trim and see if I can figure anything out there.
- Michael
|