From 9188d71e5ed3c1e0ad2b5c5a6e85e280d69d550f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Ecorchard?= Date: Fri, 2 Oct 2015 21:55:37 +0200 Subject: [PATCH] Add an example with a polyline from a numpy array --- CadQuery/Examples/Ex028_Numpy.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 CadQuery/Examples/Ex028_Numpy.py diff --git a/CadQuery/Examples/Ex028_Numpy.py b/CadQuery/Examples/Ex028_Numpy.py new file mode 100644 index 0000000..0aa12a0 --- /dev/null +++ b/CadQuery/Examples/Ex028_Numpy.py @@ -0,0 +1,26 @@ +# This example is meant to be used from within the CadQuery module of FreeCAD. +import numpy as np +import cadquery +from Helpers import show + +# Square side and offset in x and y. +side = 10 +offset = 5 + +# Define the locations that the polyline will be drawn to/thru. +# The polyline is defined as numpy.array so that operations like translation +# of all points are simplified. +pts = np.array([ + (0, 0), + (side, 0), + (side, side), + (0, side), + (0, 0), +]) + [offset, offset] + +result = cadquery.Workplane('XY') \ + .polyline(pts).extrude(2) \ + .faces('+Z').workplane().circle(side / 2).extrude(1) + +# Render the solid +show(result)