3D-City Model
    Preparing search index...

    DXFExporter – Class for exporting feature coordinates as ASCII-format DXF (AutoCAD Drawing Exchange Format).

    Supports exporting both polylines and polygons, with optional local coordinate system. Creates all required DXF header, entity, and vertex blocks for basic 3D geometries.

    const exporter = new DXFExporter();
    const dxfString = exporter.export([
    {
    coordinates: [[10, 20, 0], [20, 25, 0], [30, 15, 0]],
    name: 'Layer1',
    mode: 'polyline'
    }
    ]);
    // Save or download dxfString as .dxf file!
    Index

    Constructors

    Methods

    • Create the DXF body for an array of measurements (features). Adds polylines/polygons via DXF ENTITY/SEQ blocks.

      Parameters

      • measurements: Object[]

        Each with {coordinates, name, mode}

      Returns string

      DXF-encoded body.

    • Create a single DXF POLYLINE entity (open or closed).

      Parameters

      • coordinates: number[][]

        Vertex array.

      • name: string

        Layer name.

      • mode: string

        'polyline' (open) or 'polygon' (closed).

      Returns string

      DXF blocks as text.

    • Construct the DXF header block for a drawing with given bounding extents.

      Parameters

      • minX: number
      • minY: number
      • minZ: number
      • maxX: number
      • maxY: number
      • maxZ: number

      Returns string

      DXF header as string block

    • Export provided feature data as a plain ASCII DXF string. Optionally localizes coordinates about their centroid.

      Parameters

      • data: Object | Object[]

        One or multiple objects, each with {coordinates, name, mode}

      • Optionallocal: boolean = false

        If true, localizes coordinates relative to centroid.

      Returns string

      ASCII DXF text

      const dxf = exporter.export({coordinates: [...], name: 'Layer', mode: 'polygon'});
      
    • Compute centroid of an array of coordinates.

      Parameters

      • coordinates: number[][]

        Array of [x, y, z] coordinates.

      Returns number[]

      The centroid as [x, y, z].

    • Compute the min/max extent of an array of coordinates.

      Parameters

      • coordinates: number[][]

        Array of [x, y, z] arrays.

      Returns number[]

      [minX, maxX, minY, maxY, minZ, maxZ]

    • Localizes (translates) a coordinate array to be relative to a center point.

      Parameters

      • coordinates: number[][]

        Input coordinates.

      • center: number[]

        Center [x, y, z].

      Returns number[][]

      Localized coordinates.