- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Export Drawing File to Dxf
Hi All,.. I create a Code For External Rule In *.dwg File.
my case like this:
1. I have a Drawing file in autodesk inventor.
2. I want to create an external rule which will export the active sheet into a Dwg file with a ratio of 1: 1 Autocad File 2010
3. The location for storing the Dwg file is placed in the active document in a folder called "01.Data"
4. Name the file according to the name of the active sheet.
did anyone Have some reference?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Something like this?
Imports System.IO.Path
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
'Check it is an .idw
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MessageBox.Show("This is not a drawing. This rule can only be run in an .idw environment" & vbNewLine & "The rule will exit...", "Error Handling",MessageBoxButtons.OK,MessageBoxIcon.Error)
Return
End If
' Check that this file has been saved and actually exists on disk
If String.IsNullOrEmpty(ThisDoc.Path) Then
MessageBox.Show("This file has not yet been saved and doesn't exist on disk!" & vbLf & "Please save it first","Error Handling",MessageBoxButtons.OK,MessageBoxIcon.Error)
Return
End If
strPath_Original = ThisDoc.Path
strExportPath = ThisDoc.Path & "\01.Data\"
If System.IO.Directory.Exists(strExportPath) = False Then
System.IO.Directory.CreateDirectory(strExportPath)
End If
Dim strIniFile As String
strIniFile = "C:\path to export file\ExportDWG.ini"
'Check that the export configuration file is downloaded
If System.IO.File.Exists(strIniFile) = False Then
MessageBox.Show("Cannot find the export configuration file: " & vbNewLine & strIniFile & vbNewLine & "The rule will exit...", "Error Handling", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
i = 0
For Each S As Sheet In oDDoc.Sheets
i += 1
If S Is oDDoc.ActiveSheet Then
ExportFilename = strExportPath & "Sheet " & i & "_DWG 2D.dwg"
End If
Next
' Get the DWG translator Add-In
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the DXF target file name
oDataMedium.FileName = ExportPath & ExportFilename
MessageBox.Show(oDataMedium.FileName, "Filename")
Try
'Publish document
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Catch
MessageBox.Show("Error writing out DWG", "Error Handling",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try
Export file attached, just unzip and put it somewhere with your system files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Have you unzipped the .ini file and set the correct path in the rule to find it?
Dim strIniFile As String strIniFile = "C:\path to export file\ExportDWG.ini"
Beyond that, I'm not sure what to suggest. It is strange that you are getting errors from line 1 onwards.
Can you open the ilogic rule in the editor and send a screenshot through?