Question:
When we export document to DWG, the options are provided with an *,ini file. It works well with the DrawingDocument. While when saving as part/assembly file to DWG, there are some other options.
But it looks *.ini file does not work with Part or Assembly. How can we configure them?
Solution:
Those additional options can be explicitly appended to Option array. The code below is a demo.
Public Sub PublishDWG() ' Get the DWG translator Add-In. Dim DWGAddIn As TranslatorAddIn Set DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") 'Set a reference to the active document (the document to be published). Dim oDocument As Document Set oDocument = ThisApplication.ActiveDocument 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 DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then If oDocument.DocumentType = kPartDocumentObject Or oDocument.DocumentType = kAssemblyDocumentObject Then oOptions.Value("Solid") = True oOptions.Value("Surface") = True oOptions.Value("Sketch") = True oOptions.Value("DwgVersion") = 31 End If If oDocument.DocumentType = kDrawingDocumentObject Then Dim strIniFile As String strIniFile = "C:\tempDWGOut.ini" ' Create the name-value that specifies the ini file to use. oOptions.Value("Export_Acad_IniFile") = strIniFile End If End If 'Set the destination file name oDataMedium.FileName = "c:\tempdwgout.dwg" 'Publish document. Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub