From b3e88ecd97eae657cf1b7b557f0cd3f2dfb5cb28 Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Fri, 29 Apr 2016 17:11:48 -0400 Subject: [PATCH] Added an example of how to use the sweep operation. --- CadQuery/Examples/Ex031_Sweep.py | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 CadQuery/Examples/Ex031_Sweep.py diff --git a/CadQuery/Examples/Ex031_Sweep.py b/CadQuery/Examples/Ex031_Sweep.py new file mode 100644 index 0000000..16201b9 --- /dev/null +++ b/CadQuery/Examples/Ex031_Sweep.py @@ -0,0 +1,42 @@ +# This example is meant to be used from within the CadQuery module for FreeCAD +import cadquery +from Helpers import show + +# Points we will use to create spline and polyline paths to sweep over +pts = [ + (0, 1), + (1, 2), + (2, 4) +] + +# Spline path generated from our list of points (tuples) +path = cadquery.Workplane("XZ").spline(pts) + +# Sweep a circle with a diameter of 1.0 units along the spline path we just created +defaultSweep = cadquery.Workplane("XY").circle(1.0).sweep(path) + +# Sweep defaults to making a solid and not generating a Frenet solid. Setting Frenet to True helps prevent creep in +# the orientation of the profile as it is being swept +frenetShell = cadquery.Workplane("XY").circle(1.0).sweep(path, makeSolid=False, isFrenet=True) + +# We can sweep shapes other than circles +defaultRect = cadquery.Workplane("XY").rect(1.0, 1.0).sweep(path) + +# Switch to a polyline path, but have it use the same points as the spline +path = cadquery.Workplane("XZ").polyline(pts) + +# Using a polyline path leads to the resulting solid having segments rather than a single swept outer face +plineSweep = cadquery.Workplane("XY").circle(1.0).sweep(path) + +# Switch to an arc for the path +path = cadquery.Workplane("XZ").threePointArc((1.0, 1.5), (0.0, 1.0)) + +# Use a smaller circle section so that the resulting solid looks a little nicer +arcSweep = cadquery.Workplane("XY").circle(0.5).sweep(path) + +# Translate the resulting solids so that they do not overlap and display them left to right +show(defaultSweep) +show(frenetShell.translate((5, 0, 0))) +show(defaultRect.translate((10, 0, 0))) +show(plineSweep.translate((15, 0, 0))) +show(arcSweep.translate((20, 0, 0))) \ No newline at end of file