-
Notifications
You must be signed in to change notification settings - Fork 390
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:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="100.0"
height="100.0"
>
<g transform="scale(0.75, -0.75) translate(0.0,-100.0)" stroke-width="1.0" fill="none">
<!-- hidden lines -->
<g stroke="rgb(0,0,255)" fill="none" stroke-dasharray="1.0,1.0" >
</g>
<!-- solid lines -->
<g stroke="rgb(255,0,0)" fill="none">
<path d="M0.0,0.0 L100.0,0.0 " />
<path d="M100.0,0.0 L100.0,100.0 " />
<path d="M100.0,100.0 L0.0,100.0 " />
<path d="M0.0,100.0 L0.0,0.0 " />
</g>
</g>
</svg>
The counterpart with OpenSCAD would look like:
// OpenSCAD: export_svg
square(size=100,center=false);
with the output correctly scaled:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100mm" height="100mm" viewBox="0 -100 100 100" xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>OpenSCAD Model</title>
<path d="
M 0,-0 L 100,-0 L 100,-100 L 0,-100 z
" stroke="black" fill="lightgray" stroke-width="0.5"/>
</svg>