It doesn't look like it will directly but I bet we can saveas a .sat file and then open that and export the new .ipt all with iLogic. I'll work on some code at break tomorrow.
Unfortunately, Inventor API does not support to export to step file directly. But, try to export to .sat file and open in Inventor file. Finally, .sat file can be exported to required .step file.
Please log this wish list at idea station using below link.
https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232
Thanks and regards,
I have this code for exporting out step files with no dialog windows through ilogic, but I've tried it on a couple of sheet metal flat patterns and I think it just exports out the folded part.
Stepfilename = ThisDoc.PathAndFileName(False)
CurrentFile = Stepfilename & ".stp"
' Get the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById _
("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument _
, oContext, oOptions) Then
oOptions.Value("ApplicationProtocolType") = 3
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium
oData = ThisApplication.TransientObjects.CreateDataMedium
' Set export name of STEP file
oData.FileName = CurrentFile
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext _
, oOptions, oData)
End If
I also have this code for unfolding a sheet metal part:
Dim oDoc As PartDocument
oDoc = ThisDoc.Document
check = 0
' Make sure the document is a sheet metal document.
If oDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox("A sheet metal document must be open.")
Exit Sub
End If
'flatten sheet metal
Dim oSheetMetalCompDef As SheetMetalComponentDefinition
oSheetMetalCompDef = oDoc.ComponentDefinition
If Not oSheetMetalCompDef.HasFlatPattern Then
Try
oSheetMetalCompDef.Unfold()
Catch
MsgBox("This part does not have a flat pattern.")
End Try
oDoc.Update2(True)
End If
I tried combining them to see if that would export out the flat pattern but no luck so far. Maybe if you play around with these codes though, you'll be able to.
@S_May sorry that "tomorrow" came so late
@acanx21 thanks for the Step file code that saved me a ton of time
I wasn't able to use the true "flat pattern" but I did manage to flatten the part, save the .STEP, and unfold the part again (based off a suggestion from @dean.morrison at https://forums.autodesk.com/t5/inventor-customization/flat-pattern-export-to-new-part/m-p/7681298#M7...)...
Dim app As Inventor.Application = ThisApplication Dim oDoc As PartDocument = ThisDoc.Document ' Make sure the document is a sheet metal document. If oDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then MsgBox("A sheet metal document must be open.") Exit Sub End If Dim oTransMgr As TransactionManager = app.TransactionManager Dim oTrans As Transaction = oTransMgr.StartTransaction(oDoc, "MakePartFlat") 'will be used to undo to this point 'flatten sheet metal Dim CompDef As SheetMetalComponentDefinition CompDef = oDoc.ComponentDefinition Dim oFeatures As SheetMetalFeatures = CompDef.Features Dim BaseFace As Face 'BaseFace = app.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the stationary face.") BaseFace = oFeatures.ContourFlangeFeatures(1).Faces(2) 'this line may not work all the time, the line above can be used instead if this gives you trouble oFeatures.UnfoldFeatures.Add(BaseFace) 'CreateSTEP Stepfilename = ThisDoc.PathAndFileName(False) CurrentFile = Stepfilename & ".stp" ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById _ ("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument _ , oContext, oOptions) Then oOptions.Value("ApplicationProtocolType") = 3 oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium ' Set export name of STEP file oData.FileName = CurrentFile oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext _ , oOptions, oData) End If oTrans.End 'end undo point Dim undoCmd As ControlDefinition = app.CommandManager.ControlDefinitions("AppUndoCmd") undoCmd.Execute 'undo unfold