Jump to content

Delete / Suppress feature in Inventor


swestbrook60

Recommended Posts

Does anyone know how I can loop through existing features in an Inventor part file and suppress or delete specific ones as required? I am working in C# and a snippet of code would be appreciated (VB is fine too).

Link to comment
Share on other sites

I figured it out. Here is a bit of code showing how.

Notes:

1. You have to loop from the highest possible index backwards to 1 because the highest index no longer exists once you delete an item.

2. You have to know the feature type you are looking for, in this example a hole feature.

 

int num = partDoc.ComponentDefinition.Features.HoleFeatures.Count;

for (int i = num; i >= 1; i--)

{

partName = partDoc.ComponentDefinition.Features.HoleFeatures.Name;

if (partName.Contains("Hole1"))

{

partDoc.ComponentDefinition.Features.HoleFeatures.Delete();

}

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...