Export Method (ActiveX)

Exports an AutoCAD drawing or a group of saved layer settings to a file.

Supported platforms: Windows only

Signature - Document

VBA:

object.Export FileName, Extension, SelectionSet
object

Type: Document

The object this method applies to.

FileName

Access: Input-only

Type: String

The name for the newly exported file.

Extension

Access: Input-only

Type: String

This string should contain three characters specifying the type of file to export the drawing into. Case is not important. Use one of the following extensions: .wmf, .sat, .eps, .dxf, or .bmp.

SelectionSet

Access: Input-only

Type: SelectionSet

For WMF, SAT, and BMP formats, the selection set specifies the objects to be exported. For EPS and DXF formats, the selection set is ignored and the entire drawing is exported.

Signature - LayerStateManager

VBA:

object.Export Name, FileName
object

Type: LayerStateManager

The object this method applies to.

Name

Access: Input-only

Type: String

The name of the saved layer settings you are exporting.

FileName

Access: Input-only

Type: String

The name of the file you are exporting layer settings to.

Return Value (RetVal)

No return value.

Remarks

When exporting to WMF or BMP formats, the selection set specifies the objects from the drawing to export. If an empty selection set is provided, the user is prompted to select objects. If Nothing is provided, not an empty selection set, the entire drawing is exported.

When exporting to SAT format, the selection set specified must contain one or more objects. This selection set specifies the objects from the drawing to export. Only Region objects, 3DSolid objects, non-manifold solids, and other ShapeManager entities that do not fit the characteristics of the 3DSolid or Region objects will be exported; all other objects in the selection set will be ignored. If an empty selection set is provided, the method is executed without an error and no objects are exported.

When exporting to EPS or DXF formats, the selection set is ignored and the entire drawing is exported.

When exporting saved layer settings, you must name your output file with a .las extension in order for AutoCAD to automatically identify it as a saved layer settings export file.

Examples

VBA:

Sub Example_Export()
    ' This example exports the current drawing to DXF format.
    ' Note that a valid selection set must be provided, even
    ' though the contents of the selection set are ignored.
    
    ' Define the name for the exported file
    Dim exportFile As String
    exportFile = "C:\AutoCAD\DXFExport"     ' Adjust path to match your system
    
    ' Create an empty selection set
    Dim sset As AcadSelectionSet
    Set sset = ThisDrawing.SelectionSets.Add("TEST")
    
    ' Export the current drawing to the file specified above.
    ThisDrawing.Export exportFile, "DXF", sset
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Export()
    ;; This example exports the current drawing to DXF format.
    ;; Note that a valid selection set must be provided, even
    ;; though the contents of the selection set are ignored.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))     
    
    ;; Define the name for the exported file
    (setq exportFile "C:\\AutoCAD\\DXFExport")     ;; Adjust path to match your system
    
    ;; Create an empty selection set
    (setq sset (vla-Add (vla-get-SelectionSets doc) "TEST"))
    (vla-Select sset acSelectionSetAll)
    
    ;; Export the current drawing to the file specified above.
    (vla-Export doc exportFile "DXF" sset)

    (vla-Delete sset)
)