From 94e09761191274ffee2eb96d455bed46f8975b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Urba=C5=84czyk?= Date: Sun, 31 Jan 2021 19:00:21 +0100 Subject: [PATCH] Fix examples and start testing them (#609) * Fix examples * Added test for examples * Fix example testing code * Sweep example fix * Reformat examples * Test examples from the docs too * Add docutils to the test requirements * Example test fix on win+cleanup * Use union --- conda/meta.yaml | 3 +- doc/examples.rst | 4 +- examples/Ex009_Polylines.py | 3 +- .../Ex010_Defining_an_Edge_with_a_Spline.py | 2 +- .../Ex013_Locating_a_Workplane_on_a_Vertex.py | 2 +- examples/Ex023_Sweep.py | 4 +- .../Ex024_Sweep_With_Multiple_Sections.py | 4 +- tests/test_examples.py | 72 +++++++++++++++++++ 8 files changed, 84 insertions(+), 10 deletions(-) create mode 100755 tests/test_examples.py diff --git a/conda/meta.yaml b/conda/meta.yaml index 4e55c553..99b09a44 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -25,7 +25,8 @@ requirements: test: requires: - - pytest + - pytest + - docutils source_files: - tests/ commands: diff --git a/doc/examples.rst b/doc/examples.rst index 257116e3..ef36c013 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -874,7 +874,7 @@ A Parametric Enclosure topOfLid = topOfLid.rotateAboutCenter((1,0,0),180) #return the combined result - result =topOfLid.combineSolids(bottom) + result =topOfLid.union(bottom) .. topic:: Api References @@ -893,7 +893,7 @@ A Parametric Enclosure * :py:meth:`Workplane.workplane` * :py:meth:`Workplane.fillet` * :py:meth:`Workplane.cut` - * :py:meth:`Workplane.combineSolids` + * :py:meth:`Workplane.union` * :py:meth:`Workplane.rotateAboutCenter` * :py:meth:`Workplane.cboreHole` * :py:meth:`Workplane.cskHole` diff --git a/examples/Ex009_Polylines.py b/examples/Ex009_Polylines.py index 70f83e87..29c17bc9 100644 --- a/examples/Ex009_Polylines.py +++ b/examples/Ex009_Polylines.py @@ -6,6 +6,7 @@ import cadquery as cq # Define the points that the polyline will be drawn to/thru pts = [ + (0, H / 2.0), (W / 2.0, H / 2.0), (W / 2.0, (H / 2.0 - t)), (t / 2.0, (H / 2.0 - t)), @@ -30,7 +31,7 @@ pts = [ # 3. Only half of the I-beam profile has been drawn so far. That half is # mirrored around the Y-axis to create the complete I-beam profile. # 4. The I-beam profile is extruded to the final length of the beam. -result = cq.Workplane("front").moveTo(0, H / 2.0).polyline(pts).mirrorY().extrude(L) +result = cq.Workplane("front").polyline(pts).mirrorY().extrude(L) # Displays the result of this script show_object(result) diff --git a/examples/Ex010_Defining_an_Edge_with_a_Spline.py b/examples/Ex010_Defining_an_Edge_with_a_Spline.py index 57b06328..d42cfea7 100644 --- a/examples/Ex010_Defining_an_Edge_with_a_Spline.py +++ b/examples/Ex010_Defining_an_Edge_with_a_Spline.py @@ -18,7 +18,7 @@ sPnts = [ # 2. Generate our plate with the spline feature and make sure it is a # closed entity -r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts).close() +r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts, includeCurrent=True).close() # 3. Extrude to turn the wire into a plate result = r.extrude(0.5) diff --git a/examples/Ex013_Locating_a_Workplane_on_a_Vertex.py b/examples/Ex013_Locating_a_Workplane_on_a_Vertex.py index 197e5c06..f9cdc100 100644 --- a/examples/Ex013_Locating_a_Workplane_on_a_Vertex.py +++ b/examples/Ex013_Locating_a_Workplane_on_a_Vertex.py @@ -11,7 +11,7 @@ result = cq.Workplane("front").box(3, 2, 0.5) # 3a. The top-most Z face is selected using the >Z selector. # 3b. The lower-left vertex of the faces is selected with the Z").vertices("Z").vertices("