Message 1 of 3
ilogic to save sheets to "AutoCAD 2000/LT 2000 DXF" with model geometry only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been able to copy codes from other people to create the following code which saves all sheets to DXF with filename_sheetname
I'm unsure whether its possible but I want the save copy as to be the file format "AutoCAD 2000/LT 2000 DXF" with model geometry only
Sub Save_As_DXF ' 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 Document oDocument = ThisApplication.ActiveDocument 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 'Gets the Workspace Path WorkspacePath= ThisDoc.WorkspacePath() 'Gets the Length of the WorkspacePath String WorkspacePathLength = Len(WorkspacePath) 'Gets just the Path of the file PathOnly = ThisDoc.Path 'Removes the Workspace Path from FullPath DirectoryPath = Strings.Right(PathOnly, PathOnly.Length-WorkspacePathLength) ' Sets directory for file save Dim DXFDirectory As String DXFDirectory = "P:\" & DirectoryPath ' Sets save name as iProperties value Dim SaveName As String SaveName = DXFDirectory & "\" &ThisDoc.FileName(False) & ".dxf" 'iProperties.Value("Project", "Part Number") ThisDoc.FileName(False) If Len(Dir(DXFDirectory, vbDirectory)) = 0 Then MkDir (DXFDirectory) End If ' Check whether the translator has 'SaveCopyAs' options If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Dim strIniFile As String strIniFile = "\\HMI-ENGINEERING\Inventor_Data\Miscellaneous\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.FileName = SaveName 'DXFDirectory && ".dxf" 'Publish document. DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 'Launch the dxf file in whatever application Windows is set to open this document type with ' i = MessageBox.Show("Preview the DXF file?", "DXF Preview",MessageBoxButtons.YesNo,MessageBoxIcon.Question) ' If i = vbYes Then ThisDoc.Launch(oDataMedium.FileName) End Sub