' Get the DXF translator Add-In. Dim DXFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") If DXFAddIn Is Nothing Then Logger.Debug("DXFAddIn Is Nothing") Logger.Info("DXFAddIn.DisplayName = " & DXFAddIn.DisplayName) 'Set a reference to the active document (the document to be published). Dim oDocument As DrawingDocument = ThisDoc.Document Dim oTO As TransientObjects = ThisApplication.TransientObjects Dim oContext As TranslationContext = oTO.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oOptions As NameValueMap = oTO.CreateNameValueMap Dim oDataMedium As DataMedium = oTO.CreateDataMedium Dim sWSPath As String = ThisDoc.WorkspacePath If sWSPath = "" Then Logger.Debug("WorkspacePath was empty!") Dim SavePath As String = sWSPath & "\Z_CUT\" Dim DXFFile As String = "" Dim sTemplate As String = sWSPath & "\MyDrawingTemplate.dwg" Dim oTempDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, sTemplate, False) ' Check whether the translator has 'SaveCopyAs' options If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Logger.Info("HasSaveCopyAsOptions = True") Dim strIniFile As String = sWSPath & "\INI_FILES\dxfout.ini" ' Create the name-value that specifies the ini file to use. oOptions.Value("Export_Acad_IniFile") = strIniFile For Each oSheet As Sheet In oDocument.Sheets Dim oCopiedSheet As Inventor.Sheet = oSheet.CopyTo(oTempDoc) oCopiedSheet.Name = oSheet.Name oTempDoc.DisplayName = oSheet.Name For Each oTempSheet As Sheet In oTempDoc.Sheets If oTempSheet IsNot oCopiedSheet Then oTempSheet.Delete Next 'oTempSheet DXFFile = SavePath & oSheet.Name & ".dxf" Logger.Info("DXFFile = " & DXFFile) oDataMedium.FileName = DXFFile Try DXFAddIn.SaveCopyAs(oTempDoc, oContext, oOptions, oDataMedium) Logger.Info("Exported DWG to following DXF file:" & vbCrLf & DXFFile) Catch oEx As Exception Logger.Info("Error exporting " & oSheet.Name & " to DXF file." _ & vbCrLf & oEx.Message & vbCrLf & oEx.StackTrace) End Try Next 'oSheet End If oTempDoc.Close(True) 'True = skip save