Hello every body. What's up?
I need a code to generate the Flat Pattern in VBA.
I made an app who sets the specific material and I would like to unfold the folded part at the same time.
I tried this code, but not works:
Dim partDoc As PartDocument
Dim sheetMetalDef As SheetMetalComponentDefinition
If (Not sheetMetalDef.HasFlatPattern()) Then
sheetMetalDef.Unfold
End If
Ladimir Abdala
ThyssenKrupp Elevadores
Brazil
Windows 7 Professional 64Bits
Inventor 2011 Pro
Solved! Go to Solution.
Solved by dean.morrison. Go to Solution.
If you found, please past clip here. Because I searched it, but all codes I tried not work.
The "action" of the "Create Flat Pattern" button is what I want.
Unsure if this is your problem, but i had to ensure that the part was a sheetmetal part.
So i use the control definition item (like pushing the convert to sheet metal button)
then my part will unfold.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oDef As ControlDefinition
Set oDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartConvertToSheetMetalCmd")
oDef.Execute
Dim oCompDef As SheetMetalComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
oCompDef.Unfold
I also use this one to switch back to the part view afterwards.
Set oDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartSwitchRepresentationCmd")
oDef.Execute
Hope this helps you.
Dean.
Great Dean!!!
Your code works as well.
It is exactly I want.
Best regards from Brazil.
Thank you very much.
Ladimir Abdala