Most NX Open methods which modify the internal NX data model perform a Model Update before returning to the calling application. A few methods are designed to be executed multiple times without Model Update and require the programmer to explicitly invoke a Model Update when the set of operations are complete. The language reference manual identifies which methods require the user to explicitly invoke Model Update. Use the following commands to invoke a Model Update.
Model Update is designed to process a list of changes in a specific order and should never be interrupted or terminated before an update is complete. Interrupting the update process can leave the NX session and part in an unpredictable state, including session and part corruption.
Interactive NX Commands are designed to define a set of changes and when complete to invoke Model Update to execute the desired changes. So interrupting an interactive NX Command and executing a Model Update can also leave the NX session and part in an unpredictable state.
To enable a wide range of customization, NX Open provides many methods that interrupt the normal flow of NX to execute custom application code. For example, a User Defined Object can provide an update callback that is executed during the Model Update process. Other examples are custom selection filters or mouse tracking callbacks which are executed in response to user actions. Also, pre/post menu item callbacks can execute just before or just after interactive NX Commands.
When coding any event handler or callback, the programmer must take care to understand the state of NX and must understand which NX Open methods may not be called within the context of the event. In general no methods should be called during a Model Update which create, edit, or delete objects which have already been processed by current model update.
Since sketches can be created interactively while creating other NX features, any Pre/Post actions added to the interactive sketcher should be limited to model checks and reporting. No model edits should be attempted while entering or exiting a sketch (See Sketcher Interactions).
Note:
A single call to model update may result in many changes to the NX session. The overall update process can be successful even when some objects fail to update. For instance, a single feature may fail to update because the parameters are no longer valid for its construction but the solid body associated with the feature may still be in a valid state. When calling model update it is important to process the error list and report any unexpected failure.
The Update class has all the methods you need to query and control the update process. To get an instance of this class, use the UpdateManager method/property on your session. Update class is also used to properly delete NX objects.
Explicit Update —You can update the NX session explicitly by calling the DoUpdate() method. You can specify an undo mark the system rolls back to in case it encounters errors.
theSession->UpdateManager()->DoUpdate( myUndoMark );
Interpart Update — You can choose to limit update only to work part by setting the interpart delay flag. If the flag is turned on, then update is only limited to the current work part. If you choose to update all the parts in the session then, 1) Turn off the interpart delay flag and then call DoUpdate() or 2) Directly call the DoInterPartUpdate()
Deleting Objects — A proper way to delete NX objects is to add them to the delete list. There is a global delete list which keeps track of all objects added to the delete list. When a model goes through update, all objects in the delete list (and the child objects dependent on it) are deleted. You can add object to the delete list using AddToDeleteList(). When you add an object to delete list, all the child objects dependent on it are notified and the child objects decide whether they too should be deleted. For example, if you delete the block feature and you have a hole on the block feature then the hole feature is also added to the delete list.
You can query all the objects in the delete list at any give time using GetDeleteList(). To remove a particular object from the delete list use RemoveFromDeleteList(). Be careful while removing objects from delete list. Only add and remove objects from the delete list that your application creates.
Update Errors — If there are any errors during the model update, then they are added to the update errorlist. You can access this list using theSession->UpdateManager()->ErrorList()->GetLength() theSession->UpdateManager()->ErrorList()->GetErrorInfo(3) //Gets the third error in the list