Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX11 - Stop error on code? 1

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
0
0
US
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)


 
Replies continue below

Recommended for you

Do you have a copy of the customer template that you have write access to? If so, the easy solution is to edit the template file and delete the datum csys. Files created based on the edited template won't have the datum csys.

If you don't have write access to the template or just really want to do it with a journal, I'd check the type of the first feature in the tree and only try to delete it if it is a datum csys feature.

www.nxjournaling.com
 
Ehaviv,
Question seems posted in the wrong thread.
yes, the navigator is more or less the only access we have to the feature tree.

Regards,
Tomas

 
Status
Not open for further replies.
Back
Top