- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @CCarreiras. I was not able to download or use your attached ZIP file, due to corporate security policy, but I did copy your code to an iLogic rule editor window, then attempt to convert it to use that second process I mentioned above. I have not tested it yet though. It essentially creates the temporary additional drawing in the background, then near the end it loops through each sheet of the initially active drawing, copies the sheet to the temp drawing, deletes all other sheets from the temp drawing, then exports that temp drawing to DXF. Once the loop is finished, it closes the temp drawing. You will either need to change the path/name of the drawing template file, or else do not specify a template drawing, since that is an optional input when creating a new one.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Return
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As DrawingDocument
oDocument = ThisApplication.ActiveDocument
Dim sTPath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.TemplatesPath
Dim sTemplate As String = sTPath & "\MyDrawingTemplate.dwg" '<<< CHANGE THIS >>>
Dim oTempDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, sTemplate, False)
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
Dim strIniFile As String
strIniFile = ThisDoc.WorkspacePath() & "\INI_FILES\dxfout.ini"
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
SavePath = ThisDoc.WorkspacePath & "\Z_CUT\"
For Each oSheet As Inventor.Sheet In oDocument.Sheets
Dim oCopiedSheet As Inventor.Sheet = oSheet.CopyTo(oTempDoc)
oTempDoc.DisplayName = oSheet.Name
For Each oTempSheet As Sheet In oTempDoc.Sheets
If oTempSheet IsNot oCopiedSheet Then oTempSheet.Delete
Next 'oTempSheet
oDataMedium.FileName = SavePath & oSheet.Name & ".dxf"
'Publish document.
Try
DXFAddIn.SaveCopyAs(oTempDoc, oContext, oOptions, oDataMedium)
Catch oEx As Exception
Logger.Info("Error exporting " & oSheet.Name & " to DXF file." _
& vbCrLf & oEx.Message & vbCrLf & oEx.StackTrace)
End Try
Next 'oSheet
oTempDoc.Close(True) 'True = skip save
Wesley Crihfield
(Not an Autodesk Employee)