when performing a SaveAs in VB .NET, if the save operation fails, NX remains in an inconsistent state
where the work part is the failed (non-existent) part, instead of rolling back to the old (good) part.
This is unfortunate and shouldn't happen.
Is there any way to rollback other then manually reopening the old part ?
Code example follows.
Running NX 7.5.
Dim partSaveStatus2 As PartSaveStatus
partSaveStatus2 = Parts.Work.SaveAs(new_workPart)
Catch ex As NXException
MsgBox("part : " & new_workPart & " has failed :" & vbCrLf & vbCrLf & ex.Message & vbCrLf, MsgBoxStyle.Exclamation, "error" )
this is what I meant by "manually reopening the old part".
My point is :
1) this situation should never happen in the first place
2) is there any option to rollback without reopening the old part ?
Create an undo mark, if the save-as operation errors, roll back to the undo mark. If a new file was created during the save-as, you might want to close & delete it.
I tried undo marks but they are only good to undo feature operations, they seem not to
be working for other commands.
Closing and deleting is just what I wished to avoid. I will issue a message error for
the user to have him to close the part.
Again, NX should prevent this inconsistent situation to happen in the first place :-/
I reported an IR for this and a PR 8254155 is going to be opened.
When you start writing code, you are essentially saying: "Move over NX, I'll take care of this...". As such, it is your responsibility to handle any errors or other odd behavior that occurs. You have the tools to do what you need to do.
There are many things that can go wrong when writing files, many of which have nothing to do specifically with NX. At a bare minimum you should check that the target location exists and you have write permission. After the SaveAs operation, check the PartSaveStatus and take action accordingly.
the "bare minimum" is what I expect NX takes care of. What I'm expected
to do is to take care of my own business, not NX's.
In this case NX is assigning the work part to a file which is not there, something
not very smart and something I have no control over.
The "bare minimum" in this case means that NX should save FIRST and THEN, IF
the save is successful, assign the work part. It doesn't seem very difficult to me, in
fact it's just matter of fixing a bug.