I'm trying to perform the following action inside the update callback for a button:
Dim sTLImportBuilder1 As NXOpen.Facet.STLImportBuilder
sTLImportBuilder1 = workPart.FacetedBodies.CreateSTLImportBuilder()
sTLImportBuilder1.File = "..."
Dim nXObject1 As NXOpen.NXObject
nXObject1 = sTLImportBuilder1.Commit()
It gives me the following error: "An operation was performed that deleted undo marks created by dialog framework."
What is the right way to do that? Or is such an operation only allowed inside the Apply or Ok callbacks? Thank you
I would only collect information in the update callback.
Creation or deletion of objects should be done in the apply callback which is called by the OK callback.
Production: NX10.0.3, VERICUT 8.1, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0
Employees of the customers, together we are strong
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide
The specific behavior varies a little bit depending on your version, but oddly enough, we have a warning in the docs about importing STL files while a Block UI Styler dialog is up.
This is from the V10 docs, under Block UI Styler -> Automation Code -> Using Undo Marks:
In automation code, you can call NXOpen or UF APIs to undo actions.
A user can work only with the undo marks that are created using the automation code. It is expected that undo marks created in any callback must be deleted in the same callback or else the dialog framework automatically deletes that undo mark after the callback execution.
You can undo up to a mark in one of the following ways.
Use direct APIs which delete the undo mark such as Session.UndoToMark(). Attempts to delete the undo marks that are created by the dialog box framework result in an exception, and the dialog box remains open.
Some indirect APIs perform actions which result in the deletion of the undo mark.
When a user attempts to undo actions up to the undo mark created by the dialog box framework, an exception occurs, and the dialog box closes. You can use such APIs only in the OK and Apply callbacks and not in any other callbacks. For example, the UF_STD_import_stl_binary_file API imports a file and removes all undo marks that exist in the NX session.
When a Block UI Styler application shows a second dialog box from the Update callback of the first dialog box, undo is unavailable. After you exit the second dialog box, there are no visible undo marks to undo operations completed in the second dialog box.