CadQuery / CadQuery/cadquery

Export SVG in Millimeter

Open
#1,282 10 comments 0 reactions 0 assignees View on GitHub
svg
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

I am trying to port some models from OpenSCAD to CadQuery. The goal ist to create a 2D-SVG-file which can be used by a CNC-Router. The CNC-Router expects that all measures are in Millimeters (at least in my country). The SVG-file produced by CadQuery seems to use pixels as unit, which does not fit for my application. I couldn't find any options to force the unit used by the exporter to be Millimeters. I would also like to know what is the correct way to disable the "projectionDir" for 2D output.

Please help. This is a functionality needed for further migrations.

Here is a small code example which shows the problem:

```
import cadquery as cq
from cadquery import exporters
part = cq.Workplane("XY").rect(100,100,centered=False)
show_object(part,name="part",options={"alpha":0.2,"color":(255,170,0)})

exporters.export(
part,
'cadquery_output.svg',
opt={
"width": 100,
"height": 100,
"marginLeft": 0,
"marginTop": 0,
"showAxes": False,
"projectionDir": (0.0,0.0,1.0),
"strokeWidth": 1.0,
"strokeColor": (255, 0, 0),
"hiddenColor": (0, 0, 255),
"showHidden": False,
},
)
```

The content of the SVG-File shows a square which is much too small:

```

```

The counterpart with OpenSCAD would look like:
```
// OpenSCAD: export_svg

square(size=100,center=false);
```
with the output correctly scaled:
```

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the exporters.export entry point and the README.md or CadQuery documentation referenced in the issue. Reproduce the 100 mm square example and inspect the generated SVG dimensions, transform, and projectionDir handling. Done means SVG output can be consumed at millimeter scale and the 2D projection behavior is clearly supported or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.