I am trying to delete curve by searching its name.
I have used below code and it is working in NX 9 and NX 10 but it is not working in NX 11.
Can anyone please help me to find my mistake ?
Sub Main theSession = Session.GetSession() workPart = theSession.Parts.Work displayPart = theSession.Parts.Display Dim Curves As CurveCollection = workPart.Curves Dim bodyname As String = Line For Each oCurve As Curve In Curves If oCurve.Name = bodyname Then Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Delete") Dim notifyOnDelete1 As Boolean notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete theSession.UpdateManager.ClearErrorList() Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.AddToDeleteList(oCurve) Dim nErrs2 As Integer nErrs2 = theSession.UpdateManager.DoUpdate(markId2) theSession.DeleteUndoMark(markId1, Nothing) End If Next End Sub
Solved! Go to Solution.
Did you get any error while running this code in NX 11.
Based on my observation, below two possibilites are there for not working.
1. Compare the string in lower case or upper case.
If oCurve.Name.ToUpper = bodyname.ToUpper Then
2. Markid2 is passed for update, but no where mention in the code. Markid1 is created before adding the curve into the delete list. So pass the Markid1 for update.
'nErrs2 = theSession.UpdateManager.DoUpdate(markId2) nErrs2 = theSession.UpdateManager.DoUpdate(markId1) theSession.DeleteUndoMark(markId1, Nothing)
CAD Automation Engineer
NX 9 | NX 11 | Teamcenter 10