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
This commit is contained in:
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 <XY selector.
|
||||
# 3c. A new workplane is created on the vertex to build future geometry on.
|
||||
result = result.faces(">Z").vertices("<XY").workplane()
|
||||
result = result.faces(">Z").vertices("<XY").workplane(centerOption="CenterOfMass")
|
||||
|
||||
# 4. A circle is drawn with the selected vertex as its center.
|
||||
# 4a. The circle is cut down through the box to cut the corner out.
|
||||
|
||||
@ -17,7 +17,7 @@ frenetShell = cq.Workplane("XY").circle(1.0).sweep(path, makeSolid=True, isFrene
|
||||
defaultRect = cq.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 = cq.Workplane("XZ").polyline(pts)
|
||||
path = cq.Workplane("XZ").polyline(pts, includeCurrent=True)
|
||||
|
||||
# Using a polyline path leads to the resulting solid having segments rather than a single swept outer face
|
||||
plineSweep = cq.Workplane("XY").circle(1.0).sweep(path)
|
||||
@ -32,5 +32,5 @@ arcSweep = cq.Workplane("XY").circle(0.5).sweep(path)
|
||||
show_object(defaultSweep)
|
||||
show_object(frenetShell.translate((5, 0, 0)))
|
||||
show_object(defaultRect.translate((10, 0, 0)))
|
||||
show_object(plineSweep.translate((15, 0, 0)))
|
||||
show_object(plineSweep)
|
||||
show_object(arcSweep.translate((20, 0, 0)))
|
||||
|
||||
@ -70,11 +70,11 @@ arcSweep = (
|
||||
.workplane(offset=-5)
|
||||
.moveTo(0, 4)
|
||||
.circle(1.5)
|
||||
.workplane(offset=5)
|
||||
.workplane(offset=5, centerOption="CenterOfMass")
|
||||
.circle(1.5)
|
||||
.moveTo(0, -8)
|
||||
.circle(1.0)
|
||||
.workplane(offset=-5)
|
||||
.workplane(offset=-5, centerOption="CenterOfMass")
|
||||
.circle(1.0)
|
||||
.sweep(path, multisection=True)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user