swestbrook60 Posted August 9, 2016 Share Posted August 9, 2016 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). Quote Link to comment Share on other sites More sharing options...
swestbrook60 Posted August 11, 2016 Author Share Posted August 11, 2016 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(); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.