# dxf2papercraft

dxf2papercraft is an open source flattener, available at [https://sourceforge.net/projects/dxf2papercraft/files](https://sourceforge.net/projects/dxf2papercraft/files/)

Documentation page: [https://dxf2papercraft.sourceforge.net](https://dxf2papercraft.sourceforge.net)

## command line options

```bash
Usage: ./dxf2papercraft [options] infile3D.dxf outfile2D.dxf
 
convert a polygonal 3D object into a 2D cut-out sheet for
producing a paper model of the object using glue and scissors
Copyright by Thomas Haenselmann <givenname@familyname.de>
 
Options:
 
 -m, --nomerge        no merging of faces into single polygon
 -n, --number         print face numbers
 -d, --divide         draw each face separate
 -o, --overlap        allow overlapping faces in cut-out sheet
 -h, --hide           hide glue tabs
 -f, --force          force glue tabs, even if intersecting faces
 -p, --split 8,17     face number 8 and 17 get disconnected from the rest
                      (use -n to see face numbers in 2D DXF file)
 -s, --strategy 0..5  0: draw smallest polygon first / 1: draw largest first
                      2: as ordered in file / 3: keep adjacent faces continuous
                      4: stretch 2D layout wide / 5: keep layout dense
 -?, --help           display this text
```

## Converting dxf2papercraft generated DXF file output to SVG

Using dxf2papercraft generates 2D DXF output from 3D DXF input. We can use some tools to convert away the DXF to a neutral format like SVG.

### kabeja (works)

Some tests with conversion of dxf2papercraft dxf output to SVG files

```bash
./dxf2papercraft/dxf2papercraft -d test3d.dxf test2d.dxf
sed -i 's/ENDSEQ/ENDSEC/g' test2d.dxf
cd kabeja/
java -jar launcher.jar -nogui -pipeline svg ../test2d.dxf ../test2d.svg
cd ../
inkscape test2d.svg
```

### OpenSCAD (failed)

The dxf generated output from dxf2papercraft is not usable with openscad (we could use openscad to convert).

```bash
import(file="/home/tomate/mightyscape/papercraft_unfold/test.dxf");
WARNING: Unsupported DXF Entity 'SEQEND' (170) in "test.dxf".
WARNING: Unsupported DXF Entity 'VERTEX' (63c) in "test.dxf".
WARNING: Unsupported DXF Entity 'POLYLINE' (170) in "test.dxf".
```

## How to create usable input files for dxf2papercraft?

dxf2papercraft only handles 3D DXF files. A lot of files are not shipped in this format. So how we can convert models to 3D DXF to use dxf2papercraft?

### Blender "Import AutoCAD DXF format (.dxf) Addon

On Linux and Windows we can use Blender to import models like STL or OBJ. We can write a usable DXF file for dxf2papercraft.

[![grafik.png](https://wiki.stadtfabrikanten.org/uploads/images/gallery/2025-06/scaled-1680-/Oz5JAHR0IIdWwMmP-grafik.png)](https://wiki.stadtfabrikanten.org/uploads/images/gallery/2025-06/Oz5JAHR0IIdWwMmP-grafik.png)

## admesh

admesh is a simple tool which works well to make 3D DXF files

```bash
sudo apt install admesh
admesh 3dprint-bolt.stl --write-dxf 3dprint-bolt.dxf
```

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code" id="bkmrk--1" style="border-width: 1px;"><div class="codeContent panelContent pdl"><div><div class="syntaxhighlighter sh-django  bash" id="bkmrk--2"></div></div></div></div>admesh is able to generate DXF files from STL files too. But trying to import larger files may give error

```bash
dimeModel::largestHandle: 0
terminate called after throwing an instance of 'std::bad_alloc'
hat(): std::bad_alloc
Aborted (core dumped)
```

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code" id="bkmrk--3" style="border-width: 1px;"><div class="codeContent panelContent pdl"><div><div class="syntaxhighlighter sh-django  bash" id="bkmrk--4"></div></div></div></div>## How to improve dxf2papercraft?

In conclusion there are some ToDos to make dxf2papercraft better

- fix ENDSEQ bug (must be named "ENDSEC")
- update dime library to most recent one
- add native SVG file export option
- make colored output
- add STL input option (integrate admesh into conversion toolchain)
- allow to disable printing out numbers
- remove duplicate lines