×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NXOpen AddToDeleteList Not Deleting Expressions

NXOpen AddToDeleteList Not Deleting Expressions

NXOpen AddToDeleteList Not Deleting Expressions

(OP)
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

RE: NXOpen AddToDeleteList Not Deleting Expressions

The expression collection has a .Delete method:

CODE --> VB.net

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

www.nxjournaling.com

RE: NXOpen AddToDeleteList Not Deleting Expressions

(OP)
Do I have to wrap this is a loop and go through each expression?

RE: NXOpen AddToDeleteList Not Deleting Expressions

(OP)
Clarification. This is a catch22 situation. I can't cycle through deleted objects and get their expressions to delete.

RE: NXOpen AddToDeleteList Not Deleting Expressions

(OP)
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()

RE: NXOpen AddToDeleteList Not Deleting Expressions

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 --> VB.net

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.DoUpdate(markId2) 


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

RE: NXOpen AddToDeleteList Not Deleting Expressions

(OP)
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"

RE: NXOpen AddToDeleteList Not Deleting Expressions

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

RE: NXOpen AddToDeleteList Not Deleting Expressions

Have you tried to rename those expressions before delete them?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources