Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic to Supress Flat Pattern Feature in a Part from assembly

1 REPLY 1
SOLVED
Reply
Message 1 of 2
gazadder
748 Views, 1 Reply

Ilogic to Supress Flat Pattern Feature in a Part from assembly

I have a flat pattern feature in a part and wish to turn it on/off based on conditions controlled from an assembly. Basically the code I have works perfectly well within the part but I wish to fire the rule from the above assembly but the rule fails (presumenbly because the code refers to the current open part). Does anyone know how to adapt this code so it can be fired from an assembly?

 

Cheers

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("10mm ADDITION")
Try


If SPIGOT_REVOLUTION <> 180 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)

'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)

'Unsuppress everything in this collection
oSMDef.FlatPattern.UnsuppressFeatures(oCADlineUnSuppress)

 
End If
Catch
End Try

 

 

1 REPLY 1
Message 2 of 2
Vladimir.Ananyev
in reply to: gazadder

When you run this rule within the assembly it should get

the runtime error at the second line because the active document is not a part but an assembly.

 

Try to replace the first two lines with the following line

Dim oDoc As PartDocument = ThisDoc.Document

 ThisDoc returns the reference to the document where the current rule is stored.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report