iLogic to delete suppressed features in .ipt

iLogic to delete suppressed features in .ipt

jamieking89
Enthusiast Enthusiast
1,185 Views
6 Replies
Message 1 of 7

iLogic to delete suppressed features in .ipt

jamieking89
Enthusiast
Enthusiast

Hi

 

I am wondering if anyone could help with wirting ilogic code i could use in a rule that will delete all suppressed features. I did find something that does this online however it wouldnt delete all in one run of the rule, it needed multiple runs.

 

Thanks

Jamie

0 Likes
Accepted solutions (2)
1,186 Views
6 Replies
Replies (6)
Message 2 of 7

mcgyvr
Consultant
Consultant
Dim oFeature As PartFeature
oFeatures = ThisApplication.ActiveDocument.ComponentDefinition.Features

For Each oFeature In oFeatures
	'get the name of the feature
	oName = oFeature.Name
	'if the feature is not active (suppressed)
If Feature.IsActive(oName) = False
	'delete it
	oFeatures(oName).delete
End If
Next


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 7

jamieking89
Enthusiast
Enthusiast

Hi mcgyvr

 

Thanks for the quick response however when trying to run a rule with that ilogic within it i get an error code. (please see attached)

0 Likes
Message 4 of 7

mcgyvr
Consultant
Consultant
Accepted solution

Try this..

I'm not positive on the answer but I suspect that feature to feature dependencies are causing errors to be generated..

This will ignore them..

 

Dim oFeature As PartFeature
oFeatures = ThisApplication.ActiveDocument.ComponentDefinition.Features

For Each oFeature In oFeatures
	'get the name of the feature
	oName = oFeature.Name
	MessageBox.Show(oName, "Processing")
	'if the feature is not active (suppressed)
If Feature.IsActive(oName) = False
	'delete it
	oFeatures(oName).delete
End If
On Error Resume Next
Next


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 5 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @jamieking89 

 

Keep in mind that if you attempt to delete a feature with dependent items (other features or sketches, etc) you will see an error... adding a resume next line should catch and silence those errors.

 

Also, just a reminder that the the Inventor Customization forum is the better forum for ilogic and coding questions:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

Here is a previous topic on that forum that relates to your question:

https://forums.autodesk.com/t5/inventor-customization/ilogic-delete-suppressed-features-and-un-used-...

 

I've asked the moderators to move your this topic to that forum.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Dim oFeature As PartFeature
oFeatures = ThisApplication.ActiveDocument.ComponentDefinition.Features

On Error Resume Next
For Each oFeature In oFeatures
	'get the name of the feature
	oName = oFeature.Name
	'if the feature is not active (suppressed)
If Feature.IsActive(oName) = False
	'delete it
	oFeatures(oName).delete
End If
Next

EESignature

Message 6 of 7

jamieking89
Enthusiast
Enthusiast

Hi Curtis

 

That now works. Thanks for that.

 

Shall keep that in mind for future when posting regarding ilogic related questions.

 

Thanks again for your help.

 

Jamie

Message 7 of 7

jamieking89
Enthusiast
Enthusiast

Thanks for you help.

 

Much appreciated.

 

Jamie