Export to Other File Formats
From AutoCAD ActiveX
If you need to use an AutoCAD drawing in another application, you can convert it to a specific format by using the Export method. This method exports the AutoCAD drawing to a WMF, SAT, EPS, DXF, or BMP format. The Export method takes three values as input: the name for the new file to be created, the extension for the new file, and the selection set of objects to export.
When exporting to WMF, SAT, or BMP format, you must provide a nonempty selection set. This selection set specifies the objects from the drawing to export. If no selection set is specified, nothing is exported and a trappable invalid argument error results.
When exporting to EPS and DXF formats, Export ignores the selection set argument, but it is still required. The entire drawing is automatically exported for these formats.
Export a drawing as a DXF file and import it again
This example creates a circle in the current drawing. It then exports the drawing to a file called DXFExprt.DXF, opens a new drawing, and imports the file. Note that an empty selection set is provided as an argument to Export. The Export method ignores selection set information when exporting a DXF file, but a syntax error results if the argument is omitted.
Sub Ch3_ImportingAndExporting()
' Create the circle for visual representationDim circleObj As AcadCircleDim centerPt(0 To 2) As DoubleDim radius As DoublecenterPt(0) = 2: centerPt(1) = 2: centerPt(2) = 0radius = 1Set circleObj = ThisDrawing.ModelSpace.AddCircle _(centerPt, radius)ThisDrawing.Application.ZoomAll' Create an empty selection setDim sset As AcadSelectionSetSet sset = ThisDrawing.SelectionSets.Add("NEWSSET")'Export the current drawing to a DXF file in the' AutoCAD temporary file directoryDim tempPath As StringDim exportFile As StringConst dxfname As String = "DXFExprt"tempPath = _ThisDrawing.Application.preferences.Files.TempFilePathexportFile = tempPath & dxfnameThisDrawing.Export exportFile, "DXF", sset' Delete the empty selection setThisDrawing.SelectionSets.Item("NEWSSET").Delete' Open a new drawingThisDrawing.Application.Documents.Add "acad.dwt"' Define the importDim importFile As StringDim insertPoint(0 To 2) As DoubleDim scalefactor As DoubleimportFile = tempPath & dxfname & ".dxf"insertPoint(0) = 0: insertPoint(1) = 0: insertPoint(2) = 0scalefactor = 2#' Import the fileThisDrawing.Import importFile, insertPoint, scalefactorThisDrawing.Application.ZoomAllEnd Sub