Last active
February 11, 2023 09:25
-
-
Save sethfischer/75534098e3a38d1d22b5cb30baaf316f to your computer and use it in GitHub Desktop.
Demo of proposed multilayer DXF utility class for CadQuery. See https://github.com/CadQuery/cadquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Multilayer DXF demo. | |
Demo of proposed multilayer DXF utility class for `CadQuery <https://github.com/CadQuery/cadquery>`_. | |
See ` DXF multilayer support #1267 <https://github.com/CadQuery/cadquery/pull/1267>`_. | |
""" | |
import cadquery as cq | |
from osr_common.cq_dxf import DxfDocument | |
spline_points = [(90, 50), (83, 60), (65, 50), (50, 33), (33, 40), (15, 35), (0, 35)] | |
spline = ( | |
cq.Workplane("XY") | |
.lineTo(100, 0) | |
.lineTo(100, 35) | |
.spline(spline_points, includeCurrent=True) | |
.close() | |
) | |
circle = cq.Workplane().moveTo(15, 15).circle(10) | |
ellipse_arc = cq.Workplane().ellipseArc(1, 2, 0, 180) | |
ellipse = cq.Workplane().moveTo(45, 15).ellipse(15, 10, 0) | |
rectangle = cq.Workplane().moveTo(70, 15).rect(10, 20) | |
fold_line = cq.Workplane().moveTo(80, -5).line(0, 70) | |
dxf = DxfDocument(setup=True) | |
dxf = ( | |
dxf.add_layer("layer_cut", color=2) | |
.add_layer("layer_line_engrave", color=3) | |
.add_layer("layer_area_engrave", color=4) | |
.add_layer("layer_fold", color=5, linetype="DASHED") | |
.add_shape(spline, "layer_cut") | |
.add_shape(ellipse, "layer_cut") | |
.add_shape(ellipse_arc, "layer_line_engrave") | |
.add_shape(circle, "layer_line_engrave") | |
.add_shape(rectangle, "layer_area_engrave") | |
.add_shape(fold_line, "layer_fold") | |
) | |
dxf.document.saveas("multilayer-demo.dxf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment