VBA to suppress model tree features by type?

VBA to suppress model tree features by type?

bradley_rinschen
Participant Participant
223 Views
1 Reply
Message 1 of 2

VBA to suppress model tree features by type?

bradley_rinschen
Participant
Participant

I need to write a macro within our automation to suppress any features created using the "mark" feature. I've found where I can do this easily if I know what the feature is named- Mark1, Mark2, etc. And I could iterate thru Mark1-10 and hope that the user didn't rename it something else, but I'd rather identify it by the TYPE of feature. Mainly: a Mark, much like a Sweep or Revolve, etc. Does Inventor have some means of identifying all features of a certain type like this to suppress them?

 

Long story short: I need to suppress all 'mark' features, run my actual macro which saves the flat state into a format for our press brake, then unsuppress all 'mark' features to return the file back to its original state. 

0 Likes
224 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @bradley_rinschen.  Yes, there is a way to do that.  Look at this VBA code example and see if this is like that you are wanting.

Sub SuppressAllMarkFeatures()
    Dim oPDoc As PartDocument
    Set oPDoc = ThisApplication.ActiveDocument
    
    Dim oPDef As PartComponentDefinition
    Set oPDef = oPDoc.ComponentDefinition
    
    Dim oMarkFeats As MarkFeatures
    Set oMarkFeats = oPDef.Features.MarkFeatures
    
    If oMarkFeats.Count = 0 Then Return
    Dim oMarkFeat As MarkFeature
    For Each oMarkFeat In oMarkFeats
        oMarkFeat.Suppressed = True
    Next oMarkFeat
    Call oPDoc.Update2(True)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes