# Export Cad

> Prepare and export the selected Rhino curves to CAD (DWG/DXF) — flatten every curve to z=0 (world XY) and convert curves to arcs + lines so AutoCAD doesn't receive NURBS with hundreds of control points, then export with a Lines-&-Arcs scheme. Non-destructive dry-run first, asks whether to work on a copy, then applies and exports. Trigger when the user wants to export/hand off to CAD / AutoCAD / DWG / DXF, flatten curves to z=0, or reduce control points for CAD. Fire on Korean or English requests, e.g. "캐드로 내보내기", "dwg export", "z 0으로 눌러", "커브 z값 0", "직선 아크로", "export to cad", "flatten to z0", "dwg/dxf 내보내기".

- Skill: `hongikarchi/export-cad` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add hongikarchi/export-cad`
- Raw SKILL.md: https://api.skillmd.com/api/skills/hongikarchi/export-cad/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: hongikarchi (https://skillmd.com/u/hongikarchi)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/hongikarchi/export-cad

---


# export-cad

Prep the **selected curves** for CAD and export DWG/DXF. Script next to this file:
`exportcad_prep.py` (dry-run by default, `CAD_APPLY=True` to apply). Two prep steps then an export
command.

## Steps
1. **Model safety — ask each run** (AskUserQuestion): work on a **SaveAs copy** (`_-SaveAs` a new
   `.3dm` via `run_command`, then operate there) or the **current doc** (prep is destructive:
   z-flatten + curve replacement). User's standing choice for exports is "ask every run".
2. **Select** the curves to export (or `_SelAll` then filter to curves — the script ignores non-curves).
3. **Dry-run.**
   ```python
   exec(open(r"<ABS>\exportcad_prep.py").read())
   ```
   Reports selected curve count + how many are off z=0.
4. **Apply prep.**
   ```python
   CAD_APPLY=True; exec(open(r"<ABS>\exportcad_prep.py").read())
   ```
   Flattens every curve to z=0 (`Transform.PlanarProjection(Plane.WorldXY)`) and converts to arcs+lines
   (`Curve.ToArcsAndLines`) so CAD gets clean geometry, not dense NURBS. Reports flattened / converted.
5. **Export.** `run_command('_-Export "C:\\path\\plan.dwg" _Enter')`. Pick a scheme:
   - **`R12 Lines & Arcs`** — fewest vertices, arcs preserved (good for CAM/clean linework).
   - **`FromIni`** — deterministic/headless: configure a scheme in `AcadSchemes`, export it to an
     `.ini`, set `CurrentOption=y`, then reference that `.ini`.
   **Verify the exact scheme-name token against the live `-Export` prompt** before hardcoding a macro
   (tokens vary by version/locale). Prefer `_English` tokens.

## Gotchas (verified where noted)
- **Flatten + convert are deterministic RhinoCommon** (no dialog): `Transform.PlanarProjection` +
  `Curve.ToArcsAndLines(tol, angleTol, 0, 0)`. Verified: a z=50 arc flattens to z=0; a wiggly NURBS
  becomes ~42 arc/line segments; straight/arc curves stay as they are.
- **`ToArcsAndLines` returns None** for some already-simple curves — the script keeps the flattened
  curve in that case (`newc = pc if pc else c`).
- **Prep is destructive** (`Objects.Replace`) — hence the copy-vs-current prompt in step 1.
- **The `-Export` step is not fully auto-verifiable** unattended (writes a file); run it with a known
  output path and confirm the scheme prompt live the first time.

## Not yet implemented
- Auto-picking/creating the DWG scheme `.ini` (currently a documented manual/one-time step).
- Non-curve export (hatches/text/dims) — this skill is curve-focused; combine with `export-*` strip
  helpers if needed.

## Reference
Built 2026-07-01 (task 6 of the 6-task suite). Flatten + arc/line APIs verified live on
`260629 main ms.3dm`. See memory `rhino-export-mechanics` and the plan.

