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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro to export only flat pattern in DXF

Message 1 of 2
139 Views, 1 Reply

Macro to export only flat pattern in DXF

Hi All!

I've got a problem, I have a macro to export pdf, dwg and dxf and I cannot figure out how to change in it to export only flat in dxf. I've been trying to change the dxf.ini file even I tried to make another sheet only with flat pattern to export only that sheet but it's not working good. 
Anybody has an idea how to do it?

I'm placing here the script for dxf below:

Private Sub PublishDXF(oDocument As Document)
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
Set DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")

Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

Dim strIniFile As String
strIniFile = "C:\Projekty\Do makr\DXF.ini"

' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile

End If

'Set the destination file name
oDataMedium.MediumType = kFileNameMedium

Dim filename, fullFileName, Revision As String
Dim oDocRevNo As Property
Set oDocRevNo = oDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number")
If UF1.CBsuffix.Value = True Then
Revision = " rev" + CStr(oDocRevNo.Value)
Else: Revision = ""
End If
filename = Left(oDocument.DisplayName, Len(oDocument.DisplayName) - 4)
fullFileName = MasterPath & oDocFileType & filename & Revision & ".dxf" 'MasterPath=folder o nazwie złożenia, Path= D.export
oDataMedium.filename = fullFileName

'Publish document.
Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
UF2.tbResult.Text = UF2.tbResult.Text & filename & ".dxf" & vbLf
End Sub

Message 2 of 2

Hi @mateusz_milekFLLWZ.  If the only DXF file you want is for the flat pattern of a sheet metal part, then you have a couple options.  You can either loop through each Sheet of the drawing, and loop through each DrawingView on each Sheet, checking each DrawingView's 'IsFlatPatternView' property to see if it is True.  However, once you find that view, I'm not sure how you can use it to get your DXF in any simply way.  The DrawingView object has a DataIO property, and a DataIO object can often be used to write its data out to external files, however, in this case it only seems to function from Apprentice to retrieve a Bitmap, and even then, only if one exists, so it can't be used to create the DXF.  Then the view's parent Sheet object also has a DataIO property, but again, that one can only be used to write DWF, not DXF, so no win there either.  If you were exporting a PDF, you could have set it up with only that one view on a sheet by itself, then make sure that sheet is 'active' before exporting the document, then set an option to only include the one sheet, but that option is not available when exporting to DXF.  You may have to dig down to the model document that the view is referencing, then get its FlatPattern object, then use the FlatPattern.DataIO to write that out to a DXF, because that's how most folks do it.

Wesley Crihfield


(Not an Autodesk Employee)

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

Post to forums  

Technology Administrators

Autodesk Design & Make Report