iLogic - Delete Feature

iLogic - Delete Feature

Anonymous
Not applicable
992 Views
3 Replies
Message 1 of 4

iLogic - Delete Feature

Anonymous
Not applicable

Requesting a code snippet that deletes a named feature(s) from a given part file.

0 Likes
Accepted solutions (1)
993 Views
3 Replies
Replies (3)
Message 2 of 4

jdkriek
Advisor
Advisor
Accepted solution

Here's an iLogic and VBA solution 😉

 

iLogic:

 

oDoc = ThisDoc.Document
oFeatures = oDoc.ComponentDefinition.Features
Try 
oFeatures("NameOfYourFeature").Delete 
Catch 
MsgBox("No feature exists with that name")
End Try

 

VBA: Could be shorter, but like the check on the name.

 

 

Public Sub RemoveFeature()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    Dim oFeature As PartFeature
    Dim oFeatures As PartFeatures
    Set oFeatures = oDoc.ComponentDefinition.Features
    For Each oFeature In oFeatures
        If oFeature.Name = "NameOfYourFeature" Then
            oFeature.Delete
        End If
    Next
End Sub


Hope this helps.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you kindly for the reply.

 

I should've deleted this topic a little while back as the exact same question was answered here:

http://forums.autodesk.com/t5/Autodesk-Inventor/Deleting-features-using-iLogic/m-p/3563592/highlight...

 

Accepting as a solution in the case someone searches this forum for the same topic.

0 Likes
Message 4 of 4

jdkriek
Advisor
Advisor

I am sorry you needed to post in another forum to get an answer. Sometimes threads in this section get overlooked.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes