Print at May 11, 2026, 10:20:06 PM

Posted by minews at May 8, 2026, 12:34:16 PM
[Plug-in] DXF Export — Export current plan view to DXF (AutoCAD R12)
LibrecCAD DXF example picture
Sweethome 3D example picture

Export DXF Plugin

Hi everyone,

I'd like to share a plug-in that exports the current plan view of a Sweet
Home 3D project to a DXF file (AutoCAD R12 format), so it can be opened
in CAD applications like LibreCAD, QCAD, BricsCAD, AutoCAD, etc.

I'm not a programmer myself — this plug-in was written for me by Claude
(an AI assistant by Anthropic) over a long back-and-forth conversation
where I described what I needed and Claude wrote, debugged and refined
the code. I'm posting it here in case it's useful to other people, and
of course you're welcome to improve it.

== What it exports ==

The plug-in adds an "Export to DXF..." item to the Plan menu. When you
run it, a dialog lets you choose which text labels to include
(room names, room areas, furniture names, dimension numbers, labels).
Then a normal save dialog asks where to write the DXF file.

The output uses these layers:

WALLS white wall outlines
ROOMS green room polygons + name + area
FURNITURE cyan top-view outline of each piece
FURN_TEXT gray furniture names
DIMENSIONS red dimension lines + numbers
LABELS yellow text labels
POLYLINES magenta free-drawn polylines

The Y axis is flipped on export so the result matches the usual CAD
convention (Y up). The DXF header sets $INSUNITS = 5 (centimeters).

== Furniture outlines ==

This is the part I'm most happy with: instead of drawing each piece as
a plain bounding rectangle, the plug-in walks the Java 3D scene graph
of the loaded model, calls ModelManager.getAreaOnFloor(Node) on each
Shape3D, and writes the resulting 2D projection. So a sofa shows its
curve, a chair shows its legs, an L-shaped desk shows its actual
footprint, and so on.

To keep file size reasonable, very small mesh parts are filtered out,
and pieces with more than 12 sub-parts are merged into a single area.
If the model can't be loaded for any reason, the plug-in falls back to
the bounding rectangle so you always get something.

== Tested with ==

Sweet Home 3D 7.5 on Windows 11
LibreCAD 2.2.1.2 (opens correctly, including Chinese text after
LibreCAD's font settings are reset to defaults)

Adobe Illustrator gave error 2067 when opening the DXF, which seems
to be Illustrator's well-known strict DXF parser. A workaround is to
open the file in LibreCAD first and re-save it; Illustrator then
accepts it.

== Source code ==

[paste the source code here, or attach the .sh3p, or link to a repo]

== Build instructions ==

You need a JDK (8 or newer) and SweetHome3D.jar from your installation.

javac -encoding UTF-8 -source 1.8 -target 1.8 \
-cp SweetHome3D.jar -d build src/com/example/dxfexport/*.java
cp src/ApplicationPlugin.properties build/
cd build && jar cf ../DXFExport-1.0.sh3p .

Double-click the resulting .sh3p, restart Sweet Home 3D, then look for
"Export to DXF..." at the bottom of the Plan menu.

== Limitations ==

- DXF dimensions are written as plain LINE + TEXT entities, not real
DIMENSION entities. They display correctly everywhere but cannot
be edited as dimension objects in CAD software.
- Curved walls are flattened into short line segments (0.5 cm
flatness).
- Chinese / non-ASCII text is encoded as \U+XXXX escapes. Modern
CAD applications display this correctly as long as the chosen
text font supports the relevant characters.

I hope this is useful to someone. Feedback and improvements are
welcome.


(Plug-in code written by Claude, an AI assistant by Anthropic)