Print at May 11, 2026, 11:03:32 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)

Posted by Keet at May 8, 2026, 1:31:00 PM
Re: [Plug-in] DXF Export — Export current plan view to DXF (AutoCAD R12)
Nice work! Every now and then there are requests for import/export from/to DXF, I'm sure there are many users that will appreciate this.

(Please remove the double-post before you get replies on both posts.)
----------------------------------------
Dodecagon.nl
1300+ 3D models, manuals, and projects

Posted by minews at May 8, 2026, 3:30:46 PM
Re: [Plug-in] DXF Export — Export current plan view to DXF (AutoCAD R12)
Thank you! I’m glad to hear that.
I also agree that DXF import/export support would be very useful for many users.
By the way, I’ve already removed the duplicate post to avoid confusion.
Thanks again for the feedback!

Posted by minews at May 8, 2026, 5:08:37 PM
Re: [Plug-in] DXF Export — Export current plan view to DXF (AutoCAD R12)
Export DXF Source Code

I couldn’t find a way to edit the original post, so I added the source code link here instead.

Posted by MarioSambol at May 9, 2026, 9:55:15 AM
Re: [Plug-in] DXF Export — Export current plan view to DXF (AutoCAD R12)
I tried the plugin and I am delighted. It is invaluable to me. The only problem is that it does not work directly in Autocad LT 2024, but it works through CorelDrw as an export again in dxf or dwg. Several of my clients are looking for drawings in dxf or dwg format. The dimensions of the drawings are accurate and everything looks great.