Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

NXOpen AddToDeleteList Not Deleting Expressions

Status
Not open for further replies.

wej0901

Mechanical
Joined
Nov 21, 2014
Messages
5
Location
US
I am using the NXOpen function AddToDeleteList to delete feature construction geometry. This function works well and deletes the construction geometry; however, it is not deleting the expressions associated with these deleted features. After running the NXOpen routine, the expressions within expressions editor can't be deleted manually either. When trying to delete the expressions manually NX says the expression is assoicated with a feature.

How can I delete unused expressions with NXOpen?

R/ WEJ0901
 
The expression collection has a .Delete method:

Code:
Try
  workPart.Expressions.Delete(expression1)
Catch ex As NXException
  'code to handle error(s)
End Try

www.nxjournaling.com
 
Do I have to wrap this is a loop and go through each expression?
 
Clarification. This is a catch22 situation. I can't cycle through deleted objects and get their expressions to delete.
 
I've found this snippet of code for cleaning the part. But can't get it to work. any ideas?

Dim partCleanup1 As PartCleanup

partCleanup1 = theSession.NewPartCleanup()
partCleanup1.TurnOffHighlighting = True
partCleanup1.DeleteUnusedObjects = True
partCleanup1.DeleteUnusedExpressions = True
partCleanup1.CleanupDraftingObjects = True
partCleanup1.CleanupFeatureData = True
partCleanup1.FixOffplaneSketchCurves = True
partCleanup1.CleanupMatingData = True
partCleanup1.DeleteUnusedFonts = True
partCleanup1.CleanupCAMObjects = True
partCleanup1.DoCleanup()
partCleanup1.Dispose()
 
Sorry, I glossed over the part where you mentioned left over expressions after deleting a feature (I originally thought you were just deleting a few expressions). The associated expressions should be deleted along with the feature. Are you performing an update after the delete?

Code:
theSession.UpdateManager.ClearErrorList()

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

Dim objects1(0) As NXObject
Dim block1 As Features.Block = CType(workPart.Features.FindObject("BLOCK(1)"), Features.Block)

objects1(0) = block1
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)

Dim notifyOnDelete2 As Boolean
notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.[highlight #FCE94F]DoUpdate(markId2)[/highlight]


If you still need to delete unused expressions, part cleanup has an option for this. You should try recording a journal while performing a part cleanup with that option and look at the resulting code.

www.nxjournaling.com
 
Thank you for helping. Yes. I performed an update after the delete. My code looks exactly what you're suggesting above. I also tried a manual part clean up and UG is still not deleting the unused expressions. It's weird. Because when I try to manually delete the expression in the editor, UG says, "This expression is not used by any loaded parts in this session" and then I hit ok and UG says, "Expression is still in use"
 
I'd try saving the part, closing down & restart NX, and try the part cleanup again. If it still gives the same conflicting messages, I'd suggest you contact GTAC with the file - something may be corrupt.

www.nxjournaling.com
 
Have you tried to rename those expressions before delete them?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top