iLogic Delete suppressed features and un-used sketches in a multibody part

iLogic Delete suppressed features and un-used sketches in a multibody part

GKPByDesign
Advocate Advocate
1,326 Views
3 Replies
Message 1 of 4

iLogic Delete suppressed features and un-used sketches in a multibody part

GKPByDesign
Advocate
Advocate

Can this be done with iLogic, I use sheet metal for most my parts. Only to delete features that are suppressed then to check again to delete sketches that are not used at all 

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

WCrihfield
Mentor
Mentor
Accepted solution

Yes. This is possible.  Below is a simple code for doing this.  However, if the suppressed feature has any consumed sketches, dependant featues / sketches, or dependant work features, it will likely throw an error.  If you wanted, you could include a line like "On Error Resume Next" just before the For Each line.  This will allow the code to continue to run when it encounters errors.  On the Delete line of code, you will notice three "False" three times.  This is where it answers the normal three questions it asks you when you delete a feature.

Dim oDoc As PartDocument = ThisDoc.Document

Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition

Dim oFeats As PartFeatures = oCompDef.Features

For Each oFeat As PartFeature In oFeats
	If oFeat.Suppressed = True Then
		oFeat.Delete(False, False, False)
	End If
Next

I hope this helps.

If this solves your problem, or answers your question, pleas click 'Accept As Solution'.

Or if this helps you along the way to reaching your goal, please click 'Like'.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

GKPByDesign
Advocate
Advocate

This looks correct, but how where would I write the error code you mention? 

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Like this...

Dim oDoc As PartDocument = ThisDoc.Document

Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition

Dim oFeats As PartFeatures = oCompDef.Features

On Error Resume Next

For Each oFeat As PartFeature In oFeats
	If oFeat.Suppressed = True Then
		oFeat.Delete(False, False, False)
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)