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: 

API help for Sync Unfold Rule and Sheet Metal Defaults

1 REPLY 1
Reply
Message 1 of 2
Mhanson3
145 Views, 1 Reply

API help for Sync Unfold Rule and Sheet Metal Defaults

I am updating a rule we run after we Copy Design a part from Vault. 

 

This rule does the following;

        Updates iproperties

        Populates a few different lists for selecting material on our form

        Updates all Styles to match the Styles Library

 

We recently discovered some features have the "Follow Defaults" checkboxes unchecked, or the "Unfold Rule" is not Default(name) or By Sheet Metal Rule on Body(name).  This has caused issues with our flat patterns not being accurate and concerns about how many times has this error passed by or could pass by in the future.

Mhanson3_0-1715353713109.png   Mhanson3_1-1715353815577.png  

 

Mhanson3_2-1715353859912.png

 

I know there are 2 manual options when you right-click a solid body.  Set Sheet Metal Rule and Sync Unfold Rule.

Mhanson3_3-1715353931219.png

 

We are trying to include this in our code to avoid future risks.  I have the coding worked out to update "Set Sheet Metal Rule" to use the Active Style.  The problem is, that if the thickness changes, the Active Style changes, but the Set Sheet Metal Rule doesn't update with the change.

Mhanson3_4-1715353990259.png    Mhanson3_6-1715354537368.png

QUESTION

How can we check Follow Defaults in all sheet metal features and in the Set Sheet Metal Rule dialog with the API?

 

 

Mhanson3_5-1715354313124.png

QUESTION

How can we run the Sync Unfold Rule using the API?

 

Any and all help is greatly appreciated.

 

Thank you,

Matt

Inventor Professional 2023.4.2

 

Labels (4)
1 REPLY 1
Message 2 of 2
Mhanson3
in reply to: Mhanson3

So I am getting closer and hoping someone more knowledgeable at coding than me could help out.

 

This code works as intended.  The problem is that I don't want to have to type out all of the possible features.

doc = ThisApplication.ActiveDocument

Dim oSMCompDef As SheetMetalComponentDefinition
oSMCompDef = doc.ComponentDefinition

Dim oSMFeature As SheetMetalFeatures = oSMCompDef.Features Dim oFaceFeature As FaceFeature For Each oFaceFeature In oSMFeature.FaceFeatures If oFaceFeature.Definition.UseDefaultSheetMetalRule = False Then ' MessageBox.Show(oFaceFeature.Name & " Found", oFaceFeature.Name & " Info") oFaceFeature.Definition.UseDefaultSheetMetalRule = True ' MessageBox.Show("Default Sheet Metal Rule wasn't used. Set to Default", "Face Feature Info") End If Next Dim oContFlgFeature As ContourFlangeFeature For Each oContFlgFeature In oSMFeature.ContourFlangeFeatures If oContFlgFeature.Definition.UseDefaultSheetMetalRule = False Then ' MessageBox.Show(oContFlgFeature.Name & " Found", oContFlgFeature.Name & " Info") oContFlgFeature.Definition.UseDefaultSheetMetalRule = True ' MessageBox.Show("Default Sheet Metal Rule wasn't used. Set to Default", "Feature Info") Else ' MessageBox.Show("Default Sheet Metal Rule Already In Use.", "Feature Info") End If Next Dim oContRollFeature As ContourRollFeature For Each oContRollFeature In oSMFeature.ContourRollFeatures If oContRollFeature.Definition.UseDefaultSheetMetalRule = False Then ' MessageBox.Show(oContRollFeature.Name & " Found", oContRollFeature.Name & " Info") oContRollFeature.Definition.UseDefaultSheetMetalRule = True ' MessageBox.Show("Default Sheet Metal Rule wasn't used. Set to Default", "Feature Info") Else ' MessageBox.Show("Default Sheet Metal Rule Already In Use.", "Feature Info") End If Next

 

I tried this bit of code to see if I could just pass thru "oCase" and "oFeatureType".  As text in a Message Box, it works great.

		Dim oFeature As PartFeature' SheetMetalFeatures' = oSMCompDef.Features
		
		For Each oFeature In oSMCompDef.Features
			Dim oCase As String
			oCase = oFeature.Type.ToString
			MessageBox.Show("Feature Type: " & oCase, "Feature Type Info") 'oFeature.Type.ToString, "Feature Type Info")
			Dim oFeatureType As String
			oFeatureType = oFeature.Type.ToString.TrimStart("k").Replace("Object","")
			MessageBox.Show("Feature Type Modified: " & oFeatureType, "Feature Type Info")

 

Passing it thru to a Select Case doesn't work so well though.

		Select Case oFeature.Type
				Case oCase
					MessageBox.Show(oCase & " Found", oCase & " Info")
					Dim oCaseFeature As ObjectCollection
						oCaseFeature = oFeature
					For Each oCaseFeature In oSMCompDef.Features
					If oCaseFeature.Definition.UseDefaultSheetMetalRule = False Then
						MessageBox.Show(oCaseFeature.Name & " Found", oCaseFeature.Name & " Info")
						oCaseFeature.Definition.UseDefaultSheetMetalRule = True
						MessageBox.Show("Default Sheet Metal Rule wasn't used.  Set to Default", "Feature Info")
					Else
						MessageBox.Show("Default Sheet Metal Rule Already In Use.", "Feature Info")
					End If
				Next

 

For a little more context, I was trying to use a similar idea to this link, without all of the debug.print;

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-DBFECEA9-4801-477F-950C-C2CF56320CE9

 

And the code is message 4 from this link;

https://forums.autodesk.com/t5/inventor-programming-ilogic/default-sheetmetal-rules-on-body/td-p/102...

 

Again, any and all help is greatly appreciated.

 

Thank you

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report