Kenja824
Automotive
- Nov 5, 2014
- 950
I recorded a little journal just to delete the datum that appears when we first create a new file, then I cleaned up any lines in the code that it didnt seem to need. Only problem is if the datum is not there to be deleted, it errors out. How do you fix this?
Reasons Why I Need This.
1) We have to use the customer template and it has the datum in it.
2) I know its super easy to delete it without a journal. Since we have a set-up button we run when we work on files to set up all the right preferences and such anyway, I was hoping to just add this delete datum code to the set-up so its just one less thing for the designers to worry about.
Here is the bit of code I have in there. Sorry, I just naturally suck with VB code.
It may be important to note that I dont want it to delete datums they may add later if someone runs the set-up button again later. So I would leave this as that particular "DATUM_CSYS(0)", so it will only delete that one datum that is there when we start a new file.
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
Dim markId5 As NXOpen.Session.UndoMarkId = Nothing
Dim objects1(0) As NXOpen.NXObject
Dim datumCsys1 As NXOpen.Features.DatumCsys = CType(workPart.Features.FindObject("DATUM_CSYS(0)"), NXOpen.Features.DatumCsys)
objects1(0) = datumCsys1
Dim nErrs1 As Integer = Nothing
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)
Dim nErrs2 As Integer = Nothing
nErrs2 = theSession.UpdateManager.DoUpdate(markId5)
theSession.DeleteUndoMark(markId2, Nothing)
Reasons Why I Need This.
1) We have to use the customer template and it has the datum in it.
2) I know its super easy to delete it without a journal. Since we have a set-up button we run when we work on files to set up all the right preferences and such anyway, I was hoping to just add this delete datum code to the set-up so its just one less thing for the designers to worry about.
Here is the bit of code I have in there. Sorry, I just naturally suck with VB code.
It may be important to note that I dont want it to delete datums they may add later if someone runs the set-up button again later. So I would leave this as that particular "DATUM_CSYS(0)", so it will only delete that one datum that is there when we start a new file.
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
Dim markId5 As NXOpen.Session.UndoMarkId = Nothing
Dim objects1(0) As NXOpen.NXObject
Dim datumCsys1 As NXOpen.Features.DatumCsys = CType(workPart.Features.FindObject("DATUM_CSYS(0)"), NXOpen.Features.DatumCsys)
objects1(0) = datumCsys1
Dim nErrs1 As Integer = Nothing
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)
Dim nErrs2 As Integer = Nothing
nErrs2 = theSession.UpdateManager.DoUpdate(markId5)
theSession.DeleteUndoMark(markId2, Nothing)