Drawing Sync Home Videos Getting Started Commands

DXF-CSV AI Guide

If you've landed here from a chat with an AI assistant (Claude, ChatGPT, etc.) wanting help analyzing or editing an AutoCAD drawing, this page explains the workflow -- fast and practical. For format details -- column definitions, entity types, group-code mapping -- see the Reference and Entities pages, or the full spec.md instead.

DXF-CSV is a simplified, tabular representation of AutoCAD drawing data -- one row per entity, plain columns for geometry and properties, with the internal AutoCAD bookkeeping (owner handles, pointers, class markers, reactors) stripped out. It's designed so an AI can read a drawing's contents directly from a CSV file, reason about the geometry, and write back changes -- without needing to parse a raw DXF or understand the AutoCAD object model.

How to give an AI your drawing

  1. In AutoCAD, run CSVOUT on your drawing. This exports the current drawing (or selection) to a .csv file in DXF-CSV format.
  2. Upload that .csv file into your chat with the AI.
  3. The AI can now read entities, layers, dimensions, and geometry directly from the table and answer questions or make edits.

How to bring AI changes back into AutoCAD

It's as simple as: install Drawing Sync, click CSV In in AutoCAD's Add-ins ribbon (or run CSVIN), and specify a CSV file.

  1. Get the resulting CSV from your chat. If the AI gives you a direct link -- an artifact or any hosted file -- CSVIN accepts an https:// URL directly as the import target, so you can skip downloading it first. Otherwise, download the .csv file from the chat.
  2. In AutoCAD, run CSVIN and specify the file or URL.
  3. CSVIN reconstructs the entities using AutoCAD's own entity-creation path (entmake), so the result is a normal, native drawing -- not an imported foreign object.

Install

Try it with a sample

Three reference files are published alongside this spec at https://drawingsync.com/dxfcsv/v1.0/:

sample_entities.csv -- one row per supported entity type

One correct row per supported entity type. Use as an encoding reference when reading or generating entity rows. Covers LINE, CIRCLE, ARC, POINT, TEXT, MTEXT, LWPOLYLINE, POLYLINE/VERTEX, SPLINE, ELLIPSE, 3DFACE, SOLID, INSERT, MESH, HELIX, and others. Each row uses realistic values with all required columns populated.

sample_tables.csv -- LAYER, LTYPE, STYLE reference

Fully populated LAYER, LTYPE, and STYLE table sections. Use as a reference for table row structure, column usage, and realistic values. Includes named linetypes (CENTER, HIDDEN, DASHED, PHANTOM), layers with lineweight and color, and text styles with shape file references.

sample_ai_bracket.csv -- AI-generated mechanical bracket

A complete minimal mechanical drawing authored by an AI consumer following the spec. Demonstrates correct AI authoring patterns: layer definitions before entity rows, correct column usage, proper default suppression, realistic geometry. sha1:396cb2c5a30e identifies the source as an empty AutoCAD 2018 template -- the standard sha1 for AI-generated content not derived from an existing drawing.

sample_ai_electrical.csv -- AI-generated 208V 3-phase schematic

A complete schematic drawing: 208V three-phase delta water heater with three heating zones, thermostats, contactors, and ground symbol. Demonstrates electrical/schematic layer vocabulary (power, bus, control, elements, labels, ground), DASHED linetype for routed conductors, centered TEXT justification for component labels, and LWPOLYLINE for component boxes. Also includes _ai layer test entities demonstrating CIRCLE, open and closed LWPOLYLINE, DASHED LINE, and centered TEXT. Use alongside sample_ai_bracket.csv for schematic domain authoring.

sample_polylines.csv -- every POLYLINE/VERTEX flag combination

Verified CSVOUT output covering all POLYLINE/VERTEX flag combinations not present in typical drawings: real-world 20×7 polygon mesh (int[70]=17, int[71]=20, int[72]=7), closed-M/N mesh (int[70]=48), polyface mesh (int[70]=64), 3D polyline (int[70]=8) with int[70]=32 vertices, spline-fit (int[70]=4) with correct insert(18)→ctrl(8)→fit(16) ordering, and curve-fit (int[70]=2) with interleaved tangent vertices. Five _ai layer notes cover: vertex ordering rules, PLINETYPE/LWPOLYLINE conversion, M×N vertex count requirement, int[70]=128 flag collision between POLYLINE and LWPOLYLINE, and guidance to prefer LWPOLYLINE for simple 2D work. Use as the reference for any POLYLINE generation -- these sequences are not easy to produce correctly from the spec alone.

sample_mtext.csv -- periodic table built entirely from MTEXT

A complete periodic table of the elements, built almost entirely from multi-line MTEXT cells. Demonstrates background fill (long[90], int[63], real[45]), defined column height (real[46]), tightened line spacing (real[44]=0.35) for fitting three-line content in a fixed-height cell, middle-center attachment (int[71]=5), and \W width-factor scaling for long element names that would otherwise overflow a narrow cell. Five _ai layer TEXT notes cover: the long[90] fill-tail structural exception (value 2 vs. 1/3/16/17), the distinction between ^J soft return (stays inside the current paragraph, responds cleanly to \H height scaling) and \P paragraph break (governed by AutoCAD's looser paragraph spacing model) -- ^J is what makes a tight fixed-height multi-line cell work, cell geometry conventions (10×10 unit cells, center-point insertion), and the \W graceful-compression pattern for overflow text. Use as the reference for any multi-line MTEXT content, background fill, or column-height work -- the formatting interactions here are not obvious from the spec alone. This is the sample behind the periodic-table image on the home page.

sample_csvout_reference.csv -- curated structural variants

Curated, hand-verified CSVOUT output covering structural variants of the most complex entity types: HATCH (19 examples covering FP_* floor-plan patterns, ESCHER, ANSI31, SOLID plain/gradient with one-color and two-color gradients, circle boundaries, islands, and mixed arc+line edge boundaries), MLINE (7 examples with int[70] flag variants), SPLINE (12 examples covering open/closed, fit-point-only, rational, and start/end tangent combinations), POLYLINE (9 examples including polygon mesh and polyface), MESH (8 examples from minimal tetrahedra to a torus with subdivision and crease values), DIMENSION (11 examples per type), TEXT alignment (all int[72]/int[73] combinations including multi-script), ACAD_TABLE (structural variants including merged cells, per-cell style overrides, and empty tables), and MULTILEADER (7 variants: default, compact/leaderless, straight, spline, right-aligned, four-leader, text-width-override). _ai layer TEXT rows are embedded throughout explaining the generation rules inline. Use as the primary reference when encoding any of these entity types for CSVIN.

Also see Full format spec -- column definitions, supported entity types, group-code mapping.

Typical analysis workflow for AI

  1. Read the trailing metadata lines after the blank separator. Parse #DXF-CSV v1.0 fixed clauses and #DXF-CSV-cond conditional clauses by splitting on |. If a #zombies: line is present, split on : then spaces to build a zombie type set.
  2. Load header row to get the column set for this file. Not all columns are present in all files -- columns reflect only the group codes present in this export.
  3. Filter structural rows: type in (SECTION, ENDSEC, BLOCK, ENDBLK, SEQEND) -- keep for block resolution but exclude from geometry analysis.
  4. Load LAYER table rows to build a layer→color and layer→linetype map.
  5. For geometry work: resolve INSERT rows by finding matching BLOCK definitions and transforming their entity coordinates. INSERT rows with no matching BLOCK definition are valid -- the block was stripped.
  6. For visualization: suppress display-only layers (DEFPOINTS, NPLT-suffixed names, ASHADE, SCRN-suffixed names). AutoCAD system layers with *ADSK_-prefixed names (e.g. *ADSK_SYSTEM_LIGHTS) may also appear -- these contain non-graphical objects and can be suppressed.
  7. If a #zombies: line is present, build a set of zombie type names. Rows matching these types have no geometry -- skip them for geometry analysis but retain them for layer/property inventory.
  8. Z coordinates present = 3D drawing. Z absent on all entities = 2D plan. Mixed = 2.5D (flat entities at various elevations).
  9. Check for TEXT entities on layer _ai or _claude -- these are AI directives. The pt[10] coordinate is the anchor for any generated output. See AI directives below.

AI directives

A TEXT or MTEXT entity on layer _ai is an AI directive -- an instruction to an AI consumer rather than drafting geometry. CSVIN ignores all entities on _ai. The pt[10] coordinate is the anchor point for any generated output.

MTEXT, "palette: scan attached PDF for annotations, street names, elevation points, area tables. columns by type. topo sorted high to low. text height 30.", _ai, 3000,2100

TEXT is supported for short directives. MTEXT is preferred -- it allows longer instructions without truncation and is more visible in AutoCAD. The directive text is plain English. There is no required syntax -- write what you want the AI to do. The coordinate tells the AI where to place any generated content in the drawing coordinate space.

Layer _claude is also supported and carries the same meaning. Use _claude when the task requires Claude specifically -- it signals to the user that the directive was authored for or by Claude, and that another AI may not produce equivalent results.

Returned CSV -- additive by default: a CSV returned in response to a directive should contain only the entities the AI added or modified -- not a copy of the source drawing. This keeps generated files small and makes import clean with no risk of overwriting existing geometry. If the task requires modifying existing entities, the user should say so explicitly in the directive.

Required columns: always include name[2] in the header. Every DXF-CSV file contains SECTION, LAYER, and LTYPE rows -- all require name[2]. A file missing name[2] from the header will have nameless structural rows and will fail to import.

Column role disambiguation -- never interchange these three:

A TEXT entity has text[1] (what it says) and layer[8] (which layer it's on) and no name[2]. A LAYER row has name[2] (the layer name) and no text[1] or layer[8]. An INSERT has name[2] (block name), layer[8] (layer it lives on), and no text[1]. A HATCH has name[2] (pattern name like ANSI31) and layer[8] (layer it lives on) and no text[1].

Column minimization: include only columns needed by the entities actually present in the file. Unused columns -- where every row has an empty value -- add width without value and increase the risk of row misalignment. If no entity in the file uses pt[12], omit pt[12] from the header entirely.

Row alignment: every row must emit exactly as many comma-separated fields as the header row. Empty cells are never omitted -- a row with 15 header columns must always produce 15 fields, using empty strings for unused positions. A single short row will shift all subsequent columns and corrupt the import.

Text height and style: use the directive entity's own real[40] (text height) as the reference size for any generated text content. If style[7] is present on the directive, use the same style. This ensures generated text reads at the correct scale for the drawing without requiring a follow-up correction.

Scope: AI directives work best for content that can be extracted from text -- annotation palettes, area tables, label sets, layer organization. Geometry tracing requires a human with an underlay.

Filled geometry -- LWPOLYLINE and SOLID

For simple filled shapes, LWPOLYLINE with per-vertex width is preferred over HATCH. HATCH is powerful but requires boundary loops, island logic, and pattern parameters -- LWPOLYLINE fill requires only geometry the AI already knows.

Filled rectangle: two-vertex closed LWPOLYLINE, horizontal segment at the vertical center of the rectangle, real[40] and real[41] both set to the rectangle height on the first vertex and 0.0 on the second. The segment draws filled at the width specified by the first vertex. int[70]=1 (closed).

LWPOLYLINE, layer, "x0,y_center x1,y_center", real[40]="h,0.0", real[41]="h,0.0", int[70]=1

Filled disc (donut): two-vertex closed LWPOLYLINE with real[42]=1.0,1.0 (bulge = full semicircle on each segment) and real[43] = diameter as constant width. Place vertices at left and right of the diameter. Both real[40] and real[41] should match real[43] on both vertices when using per-vertex width instead of constant width -- mismatched second-vertex width produces an unfilled arc.

LWPOLYLINE, layer, "cx-r,cy cx+r,cy", real[42]="1.0,1.0", real[43]=diameter, int[70]=1

Tapered triangle: single open segment from apex to base midpoint, real[40] = full height at apex vertex, 0.0 at base vertex -- produces a filled triangle pointing toward the apex. int[70]=0 (open -- closing a tapered segment creates a spike artifact).

Diamond / rhombus: three-vertex open LWPOLYLINE along the horizontal centerline. Per-vertex widths taper from zero at the left point, to full width at the center, back to zero at the right point: real[40]="0.0,w,0.0", real[41]="w,0.0,0.0". Leave int[70] absent (open) -- the shape is geometrically closed by the width profile without needing a closing segment.

SOLID entity: four-corner filled quadrilateral -- good for simple rectangles and trapezoids. Corner order is non-intuitive: pt[10]=BL, pt[11]=BR, pt[12]=TL, pt[13]=TR (not sequential around the perimeter -- pt[12] and pt[13] are swapped relative to 3DFACE). Incorrect order produces two triangles instead of a filled quad.

Draw order: entities render in CSV row order within a block or model space section -- later rows draw on top of earlier rows. Place background fills first, then overlapping geometry, then text. This is the only draw-order control available without issuing AutoCAD's DRAWORDER command after import.

Color choices for fills:

Workflow decision guide

How to reason about which workflow to recommend or generate for, based on the user's situation.

The two import paths

AutoCAD session (CSVIN command): the user runs CSVIN inside a live AutoCAD session. acdbEntMake / acdbEntMod create or update entities directly in the open drawing. AutoCAD's geometry engine is live -- computed entity properties are resolved immediately on creation. The target drawing must be open and its sha1 must match the source: clause.

DXF file (dwgsync.exe -dsm): no AutoCAD session required. dwgsync.exe merges the CSV into a DXF template file and writes a new .dxf or .dwg. AutoCAD does not need to be installed for .dxf output. The sha1 in the CSV identifies which template to merge into -- typically sha1:781e2fb2654f (new.dxf) for standalone output, or sha1:396cb2c5a30e for import into a blank AutoCAD drawing.

Nudge: after a -dsm DXF import, DIMENSION entities will have their definition points and leader geometry present but their rendered anonymous blocks (*D##) absent -- these are stripped on export and cannot be regenerated without AutoCAD's dimension engine. The user runs the Nudge option of the CSVIN command (or -nudge flag of dwgsync.exe) to open the DXF in AutoCAD and trigger regeneration. This is the most common post-import step for drawings with dimensions.

Choosing a sha1 target

Situationsha1 target-dxs scopeNotes
Generating from scratch, no source drawing396cb2c5a30e (empty AutoCAD 2018 template)TABLES,BLOCKS,ENTITIESDefine all layers, linetypes, styles, and blocks used
Generating for new.dxf standalone output781e2fb2654fTABLES(LAYER),ENTITIESMinimal template -- Standard style, layer 0, basic linetypes already present
Adding geometry to an existing drawingSource drawing sha1ENTITIES (or TABLES(LAYER),ENTITIES)Layers and blocks already exist in the drawing -- reference by name, no need to redefine
Targeting a company or domain templateCompany template sha1TABLES(LAYER),ENTITIESCompany layers, blocks, dimstyles already present -- AI can reference them by name without defining them

Layer handling

AI performs well managing layers in generative mode. The default export scope TABLES(LAYER),ENTITIES reflects this -- the LAYER table is always included so the AI has the full layer inventory, while LTYPE, STYLE, DIMSTYLE, and BLOCKS are omitted unless needed. When targeting a company or domain sha1, the AI can reference existing layer names (e.g. A-WALL, E-POWR, S-BEAM) confidently without redefining them -- the sha1 contract guarantees those layers exist in the target drawing.

When generating for sha1:396cb2c5a30e (blank template), the AI must define every layer it uses. Layer definitions before their first entity use is not required structurally -- CSVIN creates missing layers on import -- but including them makes the file self-documenting and gives the user visibility into the layer scheme.

AutoCAD not required

A DXF-CSV file can be converted to a valid .dxf without AutoCAD installed:

dwgsync.exe new.dxf -dsm drawing.csv -dxf output.dxf

new.dxf is the Drawing Sync minimal DXF template (sha1:781e2fb2654f), available at https://drawingsync.com/dxfcsv/v1.0/new.dxf. The resulting DXF contains only drafting content -- no AutoCAD plot settings bloat. Any DXF-compatible application can open it. A nudge pass in AutoCAD is needed only if the drawing contains DIMENSION entities.

CSVIN status

CSVIN is the companion import pipeline -- reads a DXF-CSV file, matches it against the original DWG via source: and sha1:, and updates changed entities directly via acdbEntMake / acdbEntMod. No DXF is generated or consumed during import.

Not supported for CSVIN: 3DSOLID, LIGHT, EXTRUDEDSURFACE, OLE2FRAME, IMAGE, VIEWPORT, PDFUNDERLAY -- these entity types cannot be created or modified via acdbEntMake / acdbEntMod. This is a permanent limitation, not planned work. CSVIN will ignore rows of these types on import.

Planned for CSVIN: paper space layout import. paper[67]=1 (default layout, *Paper_Space) is the current target. paper[67]=2 and above (additional layouts -- *Paper_Space0, *Paper_Space1, ...) will be supported as the layout enumeration scheme is extended. VIEWPORT creation remains outside CSVIN scope (acdbEntMake limitation -- permanent).

For AI assistants specifically


Drawing Sync ©2026 Code Truck LLC. All rights reserved