From 4542d15a705c8cfbbaf5323edc74392afde2a41f Mon Sep 17 00:00:00 2001 From: wes Date: Sat, 27 Apr 2024 19:30:27 -0400 Subject: [PATCH] add tolkien image, add another tree --- planter.py | 18 +++++--- svg_path.py | 4 -- tolkien.svg | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 10 deletions(-) create mode 100644 tolkien.svg diff --git a/planter.py b/planter.py index 53e321d..1387dfb 100644 --- a/planter.py +++ b/planter.py @@ -48,19 +48,22 @@ result = planter_polygon.vertices().sphere(8, combine="cut") gondor_paths, gondor_attributes = svg2paths( "/home/deck/cad_files/tree_of_gondor_small.svg" ) + gandalf_paths, gandalf_attributes = svg2paths("/home/deck/cad_files/gandalf.svg") -mordor_paths, mordor_attributes = svg2paths("/home/deck/cad_files/mordor.svg") + +tolkien_paths, tolkien_attributes = svg2paths("/home/deck/cad_files/tolkien.svg") svgs_to_render = [ - (gondor_paths, (95.03, -100, 0)), - (gandalf_paths, (-95.03, -14.5, 85)), + (gondor_paths, (95.03, -100, 0), "cut", "YZ"), + (gondor_paths, (-99, 93.02, 0), "cut", "XZ"), + (tolkien_paths, (-93.03, -14.5, 85), "cut", "YZ"), ] if RENDER_TREES: image_objects = [] - for svg_paths, translate_offsets in svgs_to_render: + for svg_paths, translate_offsets, combine, planes in svgs_to_render: image_objects.append( - Workplane("YZ") + Workplane(planes) .center(0, 75) .addSvgPath(svg_paths[0]) .extrude(-2.0) @@ -68,7 +71,10 @@ if RENDER_TREES: ) for image_object in image_objects: - result = result.cut(image_object, clean=False) + if combine == "cut": + result = result.cut(image_object, clean=False) + if combine == "union": + result = result.union(image_object, clean=False) cone = cq.Solid.makeCone(planter_radius, 33, planter_height + 95) diff --git a/svg_path.py b/svg_path.py index d379dba..dbcef0e 100644 --- a/svg_path.py +++ b/svg_path.py @@ -87,11 +87,9 @@ def addSvgPath(self, path): if isinstance(p, svgpathtools.CubicBezier): coords = (tpl(p.start), tpl(p.control1), tpl(p.control2), tpl(p.end)) res = res.bezier(coords) - print("cubic bezier") elif isinstance(p, svgpathtools.QuadraticBezier): coords = (tpl(p.start), tpl(p.control), tpl(p.end)) res = res.bezier(coords) - print("quadratic bezier") pass elif isinstance(p, svgpathtools.Arc): arc_id += 1 @@ -106,10 +104,8 @@ def addSvgPath(self, path): angle1=degrees(theta1), angle2=degrees(theta1 + delta_theta), ) - print("ellipse arc") elif isinstance(p, svgpathtools.Line): res = res.lineTo(p.end.real, p.end.imag) - print("line") if path_start == p.end: path_start = None diff --git a/tolkien.svg b/tolkien.svg new file mode 100644 index 0000000..72c90f9 --- /dev/null +++ b/tolkien.svg @@ -0,0 +1,117 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + +