Blog posts

Bio

by Luke Davenport

Not a common request this, but an interesting one perhaps you agree. 

Can you control the suppression of flat pattern features on an Inventor sheet metal part with iLogic? Every iLogic fan knows about the Component.IsActive snippet that enables suppression of part features, but features that are added specifically in the flat pattern environment are counted by Inventor as being completely separate to the normal folded model features - can be given identical names to them without any problem, and won't be recognised by the Component.IsActive command. But perhaps a brief dive into the wonderful Inventor API can help us with this? Bingo! 

Important - Just bear in mind that in my efforts to be thoughtful for you my loyal readers I've added code to suppress a whole bunch of different features called Extrusion1, Hole1, Cut1 etc etc, so you'll need to delete the parts of the code you don't need and make sure the feature names match the code before running it, otherwise you’ll get an error. The code also uses a true/false parameter called FlatFeatures so you will need to create this in the part first if you leave that line in the code. Have fun!

 

'Define and access flat pattern features

Dim oDoc As PartDocument

oDoc = ThisApplication.ActiveDocument

 

Dim oSMDef As SheetMetalComponentDefinition

oSMDef = oDoc.ComponentDefinition

 

Dim oFlatFeatures As FlatPatternFeatures

oFlatFeatures = oSMDef.FlatPattern.Features

 

'Define all the features you want to work with

Dim oExtrudeFeature As ExtrudeFeature = oFlatFeatures.Item("Extrusion1")

 

Dim oCosmeticBendFeature As CosmeticBendFeature = oFlatFeatures.Item("Cosmetic Centerline1")

 

Dim oEmbossFeature As EmbossFeature = oFlatFeatures.Item("Emboss1")

 

Dim oCutFeature As CutFeature = oFlatFeatures.Item("Cut1")

 

Dim oHoleFeature As HoleFeature = oFlatFeatures.Item("Hole1")

 

Dim oCornerRoundFeature As CornerRoundFeature = oFlatFeatures.Item("Corner Round1")

 

Dim oCornerChamferFeature As CornerChamferFeature = oFlatFeatures.Item("Corner Chamfer1")

 

Try

If FlatFeatures = False Then

 

'Create an object collection to add the features for suppression

Dim oCADlineSuppress As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

 

'Add each feature that you want to suppress to the collection

oCADlineSuppress.Add(oExtrudeFeature)

oCADlineSuppress.Add(oCosmeticBendFeature)

oCADlineSuppress.Add(oEmbossFeature)

oCADlineSuppress.Add(oCutFeature)

oCADlineSuppress.Add(oHoleFeature)

oCADlineSuppress.Add(oCornerRoundFeature)

oCADlineSuppress.Add(oCornerChamferFeature)

 

'Suppress everything in this collection

oSMDef.FlatPattern.SuppressFeatures(oCADlineSuppress)

 

Else

 

'Create an object collection to add the features for unsuppression

Dim oCADlineUnSuppress As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

 

'Add each feature that you want to unsuppress to the collection

oCADlineUnSuppress.Add(oExtrudeFeature)

oCADlineUnSuppress.Add(oCosmeticBendFeature)

oCADlineUnSuppress.Add(oEmbossFeature)

oCADlineUnSuppress.Add(oCutFeature)

oCADlineUnSuppress.Add(oHoleFeature)

oCADlineUnSuppress.Add(oCornerRoundFeature)

oCADlineUnSuppress.Add(oCornerChamferFeature)

 

'Unsuppress everything in this collection

oSMDef.FlatPattern.UnsuppressFeatures(oCADlineUnSuppress)

 

End If

Catch

End Try

Comments

1 comment

  • Avatar
    cfrederiksen

    Thank you!!

    However, I am trying to link this to an assembly, so that when I turn a component on or off it changes the flat pattern in the part.

    What I have written is

    If FlatFeature then

    Parameter(PN0377349-002:1", "FlatFeatures") = True

    Else

    Parameter("PN0377349-002:1", "FlatFeatures")= False

    End IF

    'FlatFeature is a True/False parameter in my assembly and I'm trying to link it to the FlatFeatures parameter in the part that has your code associated with it.

     

    However, this does not work and I get an error about the  cast COM object unable to...

     

Please sign in to leave a comment.