Message 1 of 10
Need help on Flat pattern export to dxf (VBA)

Not applicable
11-16-2010
06:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to develop a macro that exports all flat patterns for sheet metal components. I haven't been able to get the following code to work. It give the error message "The document you are trying to save is not a drawing document" (please see snap shot of the error mesage). could someone please review the code to see what is wrong here. thanks in advance.
Sub PublishDXF() Dim DXFAddIn As TranslatorAddIn Set DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") Dim oDocument As PartDocument Set oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext Set oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism Dim oOptions As NameValueMap Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap Dim oDataMedium As DataMedium Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium FullDXFfileNamePath = TargetFolder.Value & "\" & Left(oDocument.DisplayName, Len(oDocument.DisplayName) - 4) & ".dxf" ' Check whether the translator has 'SaveCopyAs' options If DXFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then Dim strIniFile As String strIniFile = "C:\vba test\DXFOut.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.FileName = FullDXFfileNamePath 'Publish document. 'Call DXFAddIn.SaveCopyAs(oDocument, oContext, oDataMedium) Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub