Fixed line continuations in examples per #221

This commit is contained in:
Jeremy Wright
2019-11-30 14:57:29 -05:00
parent 3d40fd1f31
commit 653549dd90
14 changed files with 116 additions and 116 deletions

View File

@ -71,8 +71,8 @@ of a working plane is at the center of the face. The default hole depth is thro
center_hole_dia = 22.0 center_hole_dia = 22.0
# Create a box based on the dimensions above and add a 22mm center hole # Create a box based on the dimensions above and add a 22mm center hole
result = cq.Workplane("XY").box(length, height, thickness) \ result = (cq.Workplane("XY").box(length, height, thickness)
.faces(">Z").workplane().hole(center_hole_dia) .faces(">Z").workplane().hole(center_hole_dia))
show_object(result) show_object(result)
@ -121,8 +121,8 @@ closed curve.
.. cq_plot:: .. cq_plot::
result = cq.Workplane("front").lineTo(2.0, 0).lineTo(2.0, 1.0).threePointArc((1.0, 1.5),(0.0, 1.0))\ result = (cq.Workplane("front").lineTo(2.0, 0).lineTo(2.0, 1.0).threePointArc((1.0, 1.5),(0.0, 1.0))
.close().extrude(0.25) .close().extrude(0.25))
show_object(result) show_object(result)
@ -152,7 +152,7 @@ A new work plane center can be established at any point.
result = result.center(1.5, 0.0).rect(0.5, 0.5) # new work center is (1.5, 0.0) result = result.center(1.5, 0.0).rect(0.5, 0.5) # new work center is (1.5, 0.0)
result = result.center(-1.5, 1.5).circle(0.25) # new work center is ( 0.0, 1.5). result = result.center(-1.5, 1.5).circle(0.25) # new work center is ( 0.0, 1.5).
#the new center is specified relative to the previous center, not global coordinates! # The new center is specified relative to the previous center, not global coordinates!
result = result.extrude(0.25) result = result.extrude(0.25)
show_object(result) show_object(result)
@ -204,8 +204,8 @@ correct for small hole sizes.
.. cq_plot:: .. cq_plot::
result = cq.Workplane("front").box(3.0, 4.0, 0.25).pushPoints ( [ ( 0,0.75 ),(0, -0.75) ]) \ result = (cq.Workplane("front").box(3.0, 4.0, 0.25).pushPoints ( [ ( 0,0.75 ),(0, -0.75) ])
.polygon(6, 1.0).cutThruAll() .polygon(6, 1.0).cutThruAll())
show_object(result) show_object(result)
.. topic:: Api References .. topic:: Api References
@ -467,9 +467,9 @@ You can create a rotated work plane by specifying angles of rotation relative to
.. cq_plot:: .. cq_plot::
result = cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").workplane() \ result = (cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").workplane()
.transformed(offset=cq.Vector(0, -1.5, 1.0),rotate=cq.Vector(60, 0, 0)) \ .transformed(offset=cq.Vector(0, -1.5, 1.0),rotate=cq.Vector(60, 0, 0))
.rect(1.5,1.5,forConstruction=True).vertices().hole(0.25) .rect(1.5,1.5,forConstruction=True).vertices().hole(0.25))
show_object(result) show_object(result)
.. topic:: Api References .. topic:: Api References
@ -492,8 +492,8 @@ In the example below, a rectangle is drawn, and its vertices are used to locate
.. cq_plot:: .. cq_plot::
result = cq.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane() \ result = (cq.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane()
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125 ) .rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125 ))
show_object(result) show_object(result)
.. topic:: Api References .. topic:: Api References
@ -538,8 +538,8 @@ and a circular section.
.. cq_plot:: .. cq_plot::
result = cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").circle(1.5) \ result = (cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").circle(1.5)
.workplane(offset=3.0).rect(0.75, 0.5).loft(combine=True) .workplane(offset=3.0).rect(0.75, 0.5).loft(combine=True))
show_object(result) show_object(result)
@ -563,8 +563,8 @@ Similar to :py:meth:`Workplane.hole` , these functions operate on a list of poin
.. cq_plot:: .. cq_plot::
result = cq.Workplane(cq.Plane.XY()).box(4,2, 0.5).faces(">Z").workplane().rect(3.5, 1.5, forConstruction=True)\ result = (cq.Workplane(cq.Plane.XY()).box(4,2, 0.5).faces(">Z").workplane().rect(3.5, 1.5, forConstruction=True)
.vertices().cboreHole(0.125, 0.25, 0.125, depth=None) .vertices().cboreHole(0.125, 0.25, 0.125, depth=None))
show_object(result) show_object(result)
@ -614,10 +614,10 @@ with just a few lines of code.
(length,height,bearing_diam, thickness,padding) = ( 30.0, 40.0, 22.0, 10.0, 8.0) (length,height,bearing_diam, thickness,padding) = ( 30.0, 40.0, 22.0, 10.0, 8.0)
result = cq.Workplane("XY").box(length,height,thickness).faces(">Z").workplane().hole(bearing_diam) \ result = (cq.Workplane("XY").box(length,height,thickness).faces(">Z").workplane().hole(bearing_diam)
.faces(">Z").workplane() \ .faces(">Z").workplane()
.rect(length-padding,height-padding,forConstruction=True) \ .rect(length-padding,height-padding,forConstruction=True)
.vertices().cboreHole(2.4, 4.4, 2.1) .vertices().cboreHole(2.4, 4.4, 2.1))
show_object(result) show_object(result)
@ -665,10 +665,10 @@ ones at 13 lines, but that's very short compared to the pythonOCC version, which
(L,w,t) = (20.0, 6.0, 3.0) (L,w,t) = (20.0, 6.0, 3.0)
s = cq.Workplane("XY") s = cq.Workplane("XY")
#draw half the profile of the bottle and extrude it # Draw half the profile of the bottle and extrude it
p = s.center(-L/2.0, 0).vLine(w/2.0) \ p = (s.center(-L/2.0, 0).vLine(w/2.0)
.threePointArc((L/2.0, w/2.0 + t),(L, w/2.0)).vLine(-w/2.0) \ .threePointArc((L/2.0, w/2.0 + t),(L, w/2.0)).vLine(-w/2.0)
.mirrorX().extrude(30.0,True) .mirrorX().extrude(30.0,True))
#make the neck #make the neck
p = p.faces(">Z").workplane().circle(3.0).extrude(2.0,True) p = p.faces(">Z").workplane().circle(3.0).extrude(2.0,True)
@ -729,9 +729,9 @@ A Parametric Enclosure
oshell = oshell.edges("|Z").fillet(p_sideRadius) oshell = oshell.edges("|Z").fillet(p_sideRadius)
#inner shell #inner shell
ishell = oshell.faces("<Z").workplane(p_thickness,True)\ ishell = (oshell.faces("<Z").workplane(p_thickness,True)
.rect((p_outerWidth - 2.0* p_thickness),(p_outerLength - 2.0*p_thickness))\ .rect((p_outerWidth - 2.0* p_thickness),(p_outerLength - 2.0*p_thickness))
.extrude((p_outerHeight - 2.0*p_thickness),False) #set combine false to produce just the new boss .extrude((p_outerHeight - 2.0*p_thickness),False) #set combine false to produce just the new boss)
ishell = ishell.edges("|Z").fillet(p_sideRadius - p_thickness) ishell = ishell.edges("|Z").fillet(p_sideRadius - p_thickness)
#make the box outer box #make the box outer box
@ -741,10 +741,10 @@ A Parametric Enclosure
POSTWIDTH = (p_outerWidth - 2.0*p_screwpostInset) POSTWIDTH = (p_outerWidth - 2.0*p_screwpostInset)
POSTLENGTH = (p_outerLength -2.0*p_screwpostInset) POSTLENGTH = (p_outerLength -2.0*p_screwpostInset)
box = box.faces(">Z").workplane(-p_thickness)\ box = (box.faces(">Z").workplane(-p_thickness)
.rect(POSTWIDTH,POSTLENGTH,forConstruction=True)\ .rect(POSTWIDTH,POSTLENGTH,forConstruction=True)
.vertices().circle(p_screwpostOD/2.0).circle(p_screwpostID/2.0)\ .vertices().circle(p_screwpostOD/2.0).circle(p_screwpostID/2.0)
.extrude((-1.0)*(p_outerHeight + p_lipHeight -p_thickness ),True) .extrude((-1.0)*(p_outerHeight + p_lipHeight -p_thickness ),True))
#split lid into top and bottom parts #split lid into top and bottom parts
(lid,bottom) = box.faces(">Z").workplane(-p_thickness -p_lipHeight ).split(keepTop=True,keepBottom=True).all() #splits into two solids (lid,bottom) = box.faces(">Z").workplane(-p_thickness -p_lipHeight ).split(keepTop=True,keepBottom=True).all() #splits into two solids
@ -835,23 +835,23 @@ regarding the underside of the brick.
s = s.faces("<Z").shell(-1.0 * t) s = s.faces("<Z").shell(-1.0 * t)
# make the bumps on the top # make the bumps on the top
s = s.faces(">Z").workplane(). \ s = (s.faces(">Z").workplane().
rarray(pitch, pitch, lbumps, wbumps, True).circle(bumpDiam / 2.0) \ rarray(pitch, pitch, lbumps, wbumps, True).circle(bumpDiam / 2.0)
.extrude(bumpHeight) .extrude(bumpHeight))
# add posts on the bottom. posts are different diameter depending on geometry # add posts on the bottom. posts are different diameter depending on geometry
# solid studs for 1 bump, tubes for multiple, none for 1x1 # solid studs for 1 bump, tubes for multiple, none for 1x1
tmp = s.faces("<Z").workplane(invert=True) tmp = s.faces("<Z").workplane(invert=True)
if lbumps > 1 and wbumps > 1: if lbumps > 1 and wbumps > 1:
tmp = tmp.rarray(pitch, pitch, lbumps - 1, wbumps - 1, center=True). \ tmp = (tmp.rarray(pitch, pitch, lbumps - 1, wbumps - 1, center=True).
circle(postDiam / 2.0).circle(bumpDiam / 2.0).extrude(height - t) circle(postDiam / 2.0).circle(bumpDiam / 2.0).extrude(height - t))
elif lbumps > 1: elif lbumps > 1:
tmp = tmp.rarray(pitch, pitch, lbumps - 1, 1, center=True). \ tmp = (tmp.rarray(pitch, pitch, lbumps - 1, 1, center=True).
circle(t).extrude(height - t) circle(t).extrude(height - t))
elif wbumps > 1: elif wbumps > 1:
tmp = tmp.rarray(pitch, pitch, 1, wbumps - 1, center=True). \ tmp = (tmp.rarray(pitch, pitch, 1, wbumps - 1, center=True).
circle(t).extrude(height - t) circle(t).extrude(height - t))
else: else:
tmp = s tmp = s
@ -1018,12 +1018,12 @@ Braille Example
line_start_pos += Point(0, -cell_geometry.interline) line_start_pos += Point(0, -cell_geometry.interline)
r = get_cylinder_radius(cell_geometry) r = get_cylinder_radius(cell_geometry)
base = base.faces('>Z').vertices('<XY').workplane() \ base = (base.faces('>Z').vertices('<XY').workplane()
.pushPoints(dot_pos).circle(r) \ .pushPoints(dot_pos).circle(r)
.extrude(r) .extrude(r))
# Make a fillet almost the same radius to get a pseudo spherical cap. # Make a fillet almost the same radius to get a pseudo spherical cap.
base = base.faces('>Z').edges() \ base = (base.faces('>Z').edges()
.fillet(r - 0.001) .fillet(r - 0.001))
hidding_box = cq.Workplane('XY').box( hidding_box = cq.Workplane('XY').box(
base_width, base_height, base_thickness, centered=(False, False, False)) base_width, base_height, base_thickness, centered=(False, False, False))
result = hidding_box.union(base) result = hidding_box.union(base)
@ -1119,7 +1119,7 @@ This specific examples generates a helical cycloidal gear.
return hypocycloid(t,r1,r2) return hypocycloid(t,r1,r2)
# create the gear profile and extrude it # create the gear profile and extrude it
result = cq.Workplane('XY').parametricCurve(lambda t: gear(t*2*pi,6,1))\ result = (cq.Workplane('XY').parametricCurve(lambda t: gear(t*2*pi,6,1))
.twistExtrude(15,90).faces('>Z').workplane().circle(2).cutThruAll() .twistExtrude(15,90).faces('>Z').workplane().circle(2).cutThruAll())
show_object(result) show_object(result)

View File

@ -13,8 +13,8 @@ center_hole_dia = 22.0 # Diameter of center hole in block
# 2. The highest (max) Z face is selected and a new workplane is created on it. # 2. The highest (max) Z face is selected and a new workplane is created on it.
# 3. The new workplane is used to drill a hole through the block. # 3. The new workplane is used to drill a hole through the block.
# 3a. The hole is automatically centered in the workplane. # 3a. The hole is automatically centered in the workplane.
result = cq.Workplane("XY").box(length, height, thickness) \ result = (cq.Workplane("XY").box(length, height, thickness)
.faces(">Z").workplane().hole(center_hole_dia) .faces(">Z").workplane().hole(center_hole_dia))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -26,12 +26,12 @@ cbore_depth = 2.1 # Bolt head pocket hole depth
# do not show up in the final displayed geometry. # do not show up in the final displayed geometry.
# 6. The vertices of the rectangle (corners) are selected, and a counter-bored # 6. The vertices of the rectangle (corners) are selected, and a counter-bored
# hole is placed at each of the vertices (all 4 of them at once). # hole is placed at each of the vertices (all 4 of them at once).
result = cq.Workplane("XY").box(length, height, thickness) \ result = (cq.Workplane("XY").box(length, height, thickness)
.faces(">Z").workplane().hole(center_hole_dia) \ .faces(">Z").workplane().hole(center_hole_dia)
.faces(">Z").workplane() \ .faces(">Z").workplane()
.rect(length - cbore_inset, height - cbore_inset, forConstruction=True) \ .rect(length - cbore_inset, height - cbore_inset, forConstruction=True)
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth) \ .vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
.edges("|Z").fillet(2.0) .edges("|Z").fillet(2.0))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -21,9 +21,9 @@ rectangle_length = 19.0 # Length of rectangular hole in cylindrical plate
# plate with a rectangular hole in the center. # plate with a rectangular hole in the center.
# 3a. circle() and rect() could be changed to any other shape to completely # 3a. circle() and rect() could be changed to any other shape to completely
# change the resulting plate and/or the hole in it. # change the resulting plate and/or the hole in it.
result = cq.Workplane("front").circle(circle_radius) \ result = (cq.Workplane("front").circle(circle_radius)
.rect(rectangle_width, rectangle_length) \ .rect(rectangle_width, rectangle_length)
.extrude(thickness) .extrude(thickness))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -34,12 +34,12 @@ thickness = 0.25 # Thickness of the plate
# 7a. Without the close(), the 2D sketch will be left open and the extrude # 7a. Without the close(), the 2D sketch will be left open and the extrude
# operation will provide unpredictable results. # operation will provide unpredictable results.
# 8. The 2D sketch is extruded into a solid object of the specified thickness. # 8. The 2D sketch is extruded into a solid object of the specified thickness.
result = cq.Workplane("front").lineTo(width, 0) \ result = (cq.Workplane("front").lineTo(width, 0)
.lineTo(width, 1.0) \ .lineTo(width, 1.0)
.threePointArc((1.0, 1.5), (0.0, 1.0)) \ .threePointArc((1.0, 1.5), (0.0, 1.0))
.sagittaArc((-0.5, 1.0), 0.2) \ .sagittaArc((-0.5, 1.0), 0.2)
.radiusArc((-0.7, -0.2), -1.5) \ .radiusArc((-0.7, -0.2), -1.5)
.close().extrude(thickness) .close().extrude(thickness))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -30,10 +30,10 @@ polygon_dia = 1.0 # The diameter of the circle enclosing the polygon points
# like cutBlind() assume a positive cut direction, but cutThruAll() assumes # like cutBlind() assume a positive cut direction, but cutThruAll() assumes
# instead that the cut is made from a max direction and cuts downward from # instead that the cut is made from a max direction and cuts downward from
# that max through all objects. # that max through all objects.
result = cq.Workplane("front").box(width, height, thickness) \ result = (cq.Workplane("front").box(width, height, thickness)
.pushPoints([(0, 0.75), (0, -0.75)]) \ .pushPoints([(0, 0.75), (0, -0.75)])
.polygon(polygon_sides, polygon_dia) \ .polygon(polygon_sides, polygon_dia)
.cutThruAll() .cutThruAll())
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -30,10 +30,10 @@ pts = [
# 3. Only half of the I-beam profile has been drawn so far. That half is # 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. # 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. # 4. The I-beam profile is extruded to the final length of the beam.
result = cq.Workplane("front").moveTo(0, H/2.0) \ result = (cq.Workplane("front").moveTo(0, H/2.0)
.polyline(pts) \ .polyline(pts)
.mirrorY() \ .mirrorY()
.extrude(L) .extrude(L))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -13,10 +13,10 @@ import cadquery as cq
# 6. Selects the vertices of the for-construction rectangle. # 6. Selects the vertices of the for-construction rectangle.
# 7. Places holes at the center of each selected vertex. # 7. Places holes at the center of each selected vertex.
# 7a. Since the workplane is rotated, this results in angled holes in the face. # 7a. Since the workplane is rotated, this results in angled holes in the face.
result = cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z") \ result = (cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z")
.workplane() \ .workplane()
.transformed(offset=(0, -1.5, 1.0), rotate=(60, 0, 0)) \ .transformed(offset=(0, -1.5, 1.0), rotate=(60, 0, 0))
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25) .rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -12,10 +12,10 @@ import cadquery as cq
# other geometry. # other geometry.
# 6. Selects the vertices of the for-construction rectangle. # 6. Selects the vertices of the for-construction rectangle.
# 7. Places holes at the center of each selected vertex. # 7. Places holes at the center of each selected vertex.
result = cq.Workplane("front").box(2, 2, 0.5)\ result = (cq.Workplane("front").box(2, 2, 0.5)
.faces(">Z").workplane() \ .faces(">Z").workplane()
.rect(1.5, 1.5, forConstruction=True).vertices() \ .rect(1.5, 1.5, forConstruction=True).vertices()
.hole(0.125) .hole(0.125))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -11,10 +11,10 @@ import cadquery as cq
# 5. Creates a workplane 3 mm above the face the circle was drawn on. # 5. Creates a workplane 3 mm above the face the circle was drawn on.
# 6. Draws a 2D circle on the new, offset workplane. # 6. Draws a 2D circle on the new, offset workplane.
# 7. Creates a loft between the circle and the rectangle. # 7. Creates a loft between the circle and the rectangle.
result = cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z") \ result = (cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z")
.circle(1.5).workplane(offset=3.0) \ .circle(1.5).workplane(offset=3.0)
.rect(0.75, 0.5) \ .rect(0.75, 0.5)
.loft(combine=True) .loft(combine=True))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -11,9 +11,9 @@ import cadquery as cq
# function. # function.
# 5a. When the depth of the counter-sink hole is set to None, the hole will be # 5a. When the depth of the counter-sink hole is set to None, the hole will be
# cut through. # cut through.
result = cq.Workplane(cq.Plane.XY()).box(4, 2, 0.5).faces(">Z") \ result = (cq.Workplane(cq.Plane.XY()).box(4, 2, 0.5).faces(">Z")
.workplane().rect(3.5, 1.5, forConstruction=True) \ .workplane().rect(3.5, 1.5, forConstruction=True)
.vertices().cskHole(0.125, 0.25, 82.0, depth=None) .vertices().cskHole(0.125, 0.25, 82.0, depth=None))
# Displays the result of this script # Displays the result of this script
show_object(result) show_object(result)

View File

@ -9,8 +9,8 @@ import cadquery as cq
# that new geometry can be built on. # that new geometry can be built on.
# 4. Draws a 2D circle on the new workplane and then uses it to cut a hole # 4. Draws a 2D circle on the new workplane and then uses it to cut a hole
# all the way through the box. # all the way through the box.
c = cq.Workplane("XY").box(1, 1, 1).faces(">Z").workplane() \ c = (cq.Workplane("XY").box(1, 1, 1).faces(">Z").workplane()
.circle(0.25).cutThruAll() .circle(0.25).cutThruAll())
# 5. Selects the face furthest away from the origin in the +Y axis direction. # 5. Selects the face furthest away from the origin in the +Y axis direction.
# 6. Creates an offset workplane that is set in the center of the object. # 6. Creates an offset workplane that is set in the center of the object.

View File

@ -4,37 +4,37 @@ import cadquery as cq
path = cq.Workplane("XZ").moveTo(-10, 0).lineTo(10, 0) path = cq.Workplane("XZ").moveTo(-10, 0).lineTo(10, 0)
# Sweep a circle from diameter 2.0 to diameter 1.0 to diameter 2.0 along X axis length 10.0 + 10.0 # Sweep a circle from diameter 2.0 to diameter 1.0 to diameter 2.0 along X axis length 10.0 + 10.0
defaultSweep = cq.Workplane("YZ").workplane(offset=-10.0).circle(2.0). \ defaultSweep = (cq.Workplane("YZ").workplane(offset=-10.0).circle(2.0).
workplane(offset=10.0).circle(1.0). \ workplane(offset=10.0).circle(1.0).
workplane(offset=10.0).circle(2.0).sweep(path, multisection=True) workplane(offset=10.0).circle(2.0).sweep(path, multisection=True))
# We can sweep thrue different shapes # We can sweep thrue different shapes
recttocircleSweep = cq.Workplane("YZ").workplane(offset=-10.0).rect(2.0, 2.0). \ recttocircleSweep = (cq.Workplane("YZ").workplane(offset=-10.0).rect(2.0, 2.0).
workplane(offset=8.0).circle(1.0).workplane(offset=4.0).circle(1.0). \ workplane(offset=8.0).circle(1.0).workplane(offset=4.0).circle(1.0).
workplane(offset=8.0).rect(2.0, 2.0).sweep(path, multisection=True) workplane(offset=8.0).rect(2.0, 2.0).sweep(path, multisection=True))
circletorectSweep = cq.Workplane("YZ").workplane(offset=-10.0).circle(1.0). \ circletorectSweep = (cq.Workplane("YZ").workplane(offset=-10.0).circle(1.0).
workplane(offset=7.0).rect(2.0, 2.0).workplane(offset=6.0).rect(2.0, 2.0). \ workplane(offset=7.0).rect(2.0, 2.0).workplane(offset=6.0).rect(2.0, 2.0).
workplane(offset=7.0).circle(1.0).sweep(path, multisection=True) workplane(offset=7.0).circle(1.0).sweep(path, multisection=True))
# Placement of the Shape is important otherwise could produce unexpected shape # Placement of the Shape is important otherwise could produce unexpected shape
specialSweep = cq.Workplane("YZ").circle(1.0).workplane(offset=10.0).rect(2.0, 2.0). \ specialSweep = (cq.Workplane("YZ").circle(1.0).workplane(offset=10.0).rect(2.0, 2.0).
sweep(path, multisection=True) sweep(path, multisection=True))
# Switch to an arc for the path : line l=5.0 then half circle r=4.0 then line l=5.0 # Switch to an arc for the path : line l=5.0 then half circle r=4.0 then line l=5.0
path = cq.Workplane("XZ").moveTo(-5, 4).lineTo(0, 4). \ path = (cq.Workplane("XZ").moveTo(-5, 4).lineTo(0, 4).
threePointArc((4, 0), (0, -4)).lineTo(-5, -4) threePointArc((4, 0), (0, -4)).lineTo(-5, -4))
# Placement of different shapes should follow the path # Placement of different shapes should follow the path
# cylinder r=1.5 along first line # cylinder r=1.5 along first line
# then sweep allong arc from r=1.5 to r=1.0 # then sweep allong arc from r=1.5 to r=1.0
# then cylinder r=1.0 along last line # then cylinder r=1.0 along last line
arcSweep = cq.Workplane("YZ").workplane(offset=-5).moveTo(0, 4).circle(1.5). \ arcSweep = (cq.Workplane("YZ").workplane(offset=-5).moveTo(0, 4).circle(1.5).
workplane(offset=5).circle(1.5). \ workplane(offset=5).circle(1.5).
moveTo(0, -8).circle(1.0). \ moveTo(0, -8).circle(1.0).
workplane(offset=-5).circle(1.0). \ workplane(offset=-5).circle(1.0).
sweep(path, multisection=True) sweep(path, multisection=True))
# Translate the resulting solids so that they do not overlap and display them left to right # Translate the resulting solids so that they do not overlap and display them left to right

View File

@ -32,23 +32,23 @@ s = cq.Workplane("XY").box(total_length, total_width, height)
s = s.faces("<Z").shell(-1.0 * t) s = s.faces("<Z").shell(-1.0 * t)
# make the bumps on the top # make the bumps on the top
s = s.faces(">Z").workplane(). \ s = (s.faces(">Z").workplane().
rarray(pitch, pitch, lbumps, wbumps, True).circle(bumpDiam / 2.0) \ rarray(pitch, pitch, lbumps, wbumps, True).circle(bumpDiam / 2.0)
.extrude(bumpHeight) .extrude(bumpHeight))
# add posts on the bottom. posts are different diameter depending on geometry # add posts on the bottom. posts are different diameter depending on geometry
# solid studs for 1 bump, tubes for multiple, none for 1x1 # solid studs for 1 bump, tubes for multiple, none for 1x1
tmp = s.faces("<Z").workplane(invert=True) tmp = s.faces("<Z").workplane(invert=True)
if lbumps > 1 and wbumps > 1: if lbumps > 1 and wbumps > 1:
tmp = tmp.rarray(pitch, pitch, lbumps - 1, wbumps - 1, center=True). \ tmp = (tmp.rarray(pitch, pitch, lbumps - 1, wbumps - 1, center=True).
circle(postDiam / 2.0).circle(bumpDiam / 2.0).extrude(height - t) circle(postDiam / 2.0).circle(bumpDiam / 2.0).extrude(height - t))
elif lbumps > 1: elif lbumps > 1:
tmp = tmp.rarray(pitch, pitch, lbumps - 1, 1, center=True). \ tmp = (tmp.rarray(pitch, pitch, lbumps - 1, 1, center=True).
circle(t).extrude(height - t) circle(t).extrude(height - t))
elif wbumps > 1: elif wbumps > 1:
tmp = tmp.rarray(pitch, pitch, 1, wbumps - 1, center=True). \ tmp = (tmp.rarray(pitch, pitch, 1, wbumps - 1, center=True).
circle(t).extrude(height - t) circle(t).extrude(height - t))
else: else:
tmp = s tmp = s