Submitted by JXB on Mon, 10/05/2015 - 05:51
Forums:
To all
I have written a few line of codes to check and delete (NX.CAE) groups (as part of program). It seems to work. However I have a question regarding the parameter required for the command: theSession.UpdateManager.DoUpdate(Session.UndoMarkId As undoMark)
I have written the line as follows and allocate a "dummy" number (999)
Dim nErrs2 As Integer = theSession.UpdateManager.DoUpdate(999)
As the code works I am not overly concerned but I am curious to know what is the effect (if any!) of not defining a session undomark. Recording a journal does not use/show an undomark!
Could it be that in a session a "conflict" between my (fixed) allocated ID (999) and an NX generated ID may exist?
Thanks
Regards
JXB
re: undo mark
If anything goes wrong during the update, the .DoUpdate method will throw an exception and roll back to the specified undo mark. By passing in a "dummy" number, you run the risk of creating an additional error should the update not be successful; or, potentially losing unsaved work done on the file should the "dummy" number coincide with a previous undo mark.
I would suggest creating an undo mark before deleting the groups for use in the .DoUpdate command. Since you are deleting existing groups, chances are good that you will not run into an update error, but better to be safe than sorry.
Thanks for the clarification.
Thanks for the clarification. Just added a UndoMarId and test code is still working!
Dim theCAEPart As CAE.CaePart = CType(theSimPart, CAE.CaePart)
Dim theUndoMarkDesc As String = "DeleteGroup"
Dim myUndoMarkID As session.UndoMarkId = theSession.SetUndoMark(Session.MarkVisibility.Visible,theUndoMarkDesc )
For Each sname As String In saGroupOutputForStress
If GroupExist(sname) = True Then
thecaeGroup = CType(theCAEPart.CaeGroups.FindObject(sname), CAE.CaeGroup)
Dim objects1(0) As NXObject
objects1(0)= thecaeGroup
Dim iErrs1 As Integer= theSession.UpdateManager.AddToDeleteList(objects1)
Dim iErrs2 As Integer = theSession.UpdateManager.DoUpdate(myUndoMarkID)
End if
Next sname
Thanks
Regards
re: undo mark
You've probably already noticed this, but you can create the undo mark as "invisible". Invisible undo marks won't show up in the undo history; the user can't make use of it in interactive NX, but your journal can. Invisible marks come in handy when you need to make several in your journal, but don't want to give the user access to them. Alternatively, if the operations complete successfully, you can delete the mark(s) when you are done with them before the journal completes.
re: undo mark - To Be Visible or Not to Be
Yes I did notice that in the doc but selected 'Visible' for my 1st test with the undo mark. I wasn't too sure which one to go for. Still undecided! Programme is not overly "clever". It's all or nothing. If it crashes half way god knows what happens to the .sim file. Having said that the file is saved after each (completed) loop so one would lose only the last loop
Thanks
Regards