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.
I know there are 2 manual options when you right-click a solid body. Set Sheet Metal Rule and Sync Unfold Rule.
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.
QUESTION
How can we check Follow Defaults in all sheet metal features and in the Set Sheet Metal Rule dialog with the API?
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
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;
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.