Fixed line continuations in examples per #221
This commit is contained in:
@ -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.
|
||||
# 3. The new workplane is used to drill a hole through the block.
|
||||
# 3a. The hole is automatically centered in the workplane.
|
||||
result = cq.Workplane("XY").box(length, height, thickness) \
|
||||
.faces(">Z").workplane().hole(center_hole_dia)
|
||||
result = (cq.Workplane("XY").box(length, height, thickness)
|
||||
.faces(">Z").workplane().hole(center_hole_dia))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -26,12 +26,12 @@ cbore_depth = 2.1 # Bolt head pocket hole depth
|
||||
# do not show up in the final displayed geometry.
|
||||
# 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).
|
||||
result = cq.Workplane("XY").box(length, height, thickness) \
|
||||
.faces(">Z").workplane().hole(center_hole_dia) \
|
||||
.faces(">Z").workplane() \
|
||||
.rect(length - cbore_inset, height - cbore_inset, forConstruction=True) \
|
||||
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth) \
|
||||
.edges("|Z").fillet(2.0)
|
||||
result = (cq.Workplane("XY").box(length, height, thickness)
|
||||
.faces(">Z").workplane().hole(center_hole_dia)
|
||||
.faces(">Z").workplane()
|
||||
.rect(length - cbore_inset, height - cbore_inset, forConstruction=True)
|
||||
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
|
||||
.edges("|Z").fillet(2.0))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -21,9 +21,9 @@ rectangle_length = 19.0 # Length of rectangular hole in cylindrical plate
|
||||
# plate with a rectangular hole in the center.
|
||||
# 3a. circle() and rect() could be changed to any other shape to completely
|
||||
# change the resulting plate and/or the hole in it.
|
||||
result = cq.Workplane("front").circle(circle_radius) \
|
||||
.rect(rectangle_width, rectangle_length) \
|
||||
.extrude(thickness)
|
||||
result = (cq.Workplane("front").circle(circle_radius)
|
||||
.rect(rectangle_width, rectangle_length)
|
||||
.extrude(thickness))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -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
|
||||
# operation will provide unpredictable results.
|
||||
# 8. The 2D sketch is extruded into a solid object of the specified thickness.
|
||||
result = cq.Workplane("front").lineTo(width, 0) \
|
||||
.lineTo(width, 1.0) \
|
||||
.threePointArc((1.0, 1.5), (0.0, 1.0)) \
|
||||
.sagittaArc((-0.5, 1.0), 0.2) \
|
||||
.radiusArc((-0.7, -0.2), -1.5) \
|
||||
.close().extrude(thickness)
|
||||
result = (cq.Workplane("front").lineTo(width, 0)
|
||||
.lineTo(width, 1.0)
|
||||
.threePointArc((1.0, 1.5), (0.0, 1.0))
|
||||
.sagittaArc((-0.5, 1.0), 0.2)
|
||||
.radiusArc((-0.7, -0.2), -1.5)
|
||||
.close().extrude(thickness))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -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
|
||||
# instead that the cut is made from a max direction and cuts downward from
|
||||
# that max through all objects.
|
||||
result = cq.Workplane("front").box(width, height, thickness) \
|
||||
.pushPoints([(0, 0.75), (0, -0.75)]) \
|
||||
.polygon(polygon_sides, polygon_dia) \
|
||||
.cutThruAll()
|
||||
result = (cq.Workplane("front").box(width, height, thickness)
|
||||
.pushPoints([(0, 0.75), (0, -0.75)])
|
||||
.polygon(polygon_sides, polygon_dia)
|
||||
.cutThruAll())
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -30,10 +30,10 @@ 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").moveTo(0, H/2.0)
|
||||
.polyline(pts)
|
||||
.mirrorY()
|
||||
.extrude(L))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -13,10 +13,10 @@ import cadquery as cq
|
||||
# 6. Selects the vertices of the for-construction rectangle.
|
||||
# 7. Places holes at the center of each selected vertex.
|
||||
# 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") \
|
||||
.workplane() \
|
||||
.transformed(offset=(0, -1.5, 1.0), rotate=(60, 0, 0)) \
|
||||
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25)
|
||||
result = (cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z")
|
||||
.workplane()
|
||||
.transformed(offset=(0, -1.5, 1.0), rotate=(60, 0, 0))
|
||||
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -12,10 +12,10 @@ import cadquery as cq
|
||||
# other geometry.
|
||||
# 6. Selects the vertices of the for-construction rectangle.
|
||||
# 7. Places holes at the center of each selected vertex.
|
||||
result = cq.Workplane("front").box(2, 2, 0.5)\
|
||||
.faces(">Z").workplane() \
|
||||
.rect(1.5, 1.5, forConstruction=True).vertices() \
|
||||
.hole(0.125)
|
||||
result = (cq.Workplane("front").box(2, 2, 0.5)
|
||||
.faces(">Z").workplane()
|
||||
.rect(1.5, 1.5, forConstruction=True).vertices()
|
||||
.hole(0.125))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -11,10 +11,10 @@ import cadquery as cq
|
||||
# 5. Creates a workplane 3 mm above the face the circle was drawn on.
|
||||
# 6. Draws a 2D circle on the new, offset workplane.
|
||||
# 7. Creates a loft between the circle and the rectangle.
|
||||
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)
|
||||
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))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -11,9 +11,9 @@ import cadquery as cq
|
||||
# function.
|
||||
# 5a. When the depth of the counter-sink hole is set to None, the hole will be
|
||||
# cut through.
|
||||
result = cq.Workplane(cq.Plane.XY()).box(4, 2, 0.5).faces(">Z") \
|
||||
.workplane().rect(3.5, 1.5, forConstruction=True) \
|
||||
.vertices().cskHole(0.125, 0.25, 82.0, depth=None)
|
||||
result = (cq.Workplane(cq.Plane.XY()).box(4, 2, 0.5).faces(">Z")
|
||||
.workplane().rect(3.5, 1.5, forConstruction=True)
|
||||
.vertices().cskHole(0.125, 0.25, 82.0, depth=None))
|
||||
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
||||
@ -9,8 +9,8 @@ import cadquery as cq
|
||||
# that new geometry can be built on.
|
||||
# 4. Draws a 2D circle on the new workplane and then uses it to cut a hole
|
||||
# all the way through the box.
|
||||
c = cq.Workplane("XY").box(1, 1, 1).faces(">Z").workplane() \
|
||||
.circle(0.25).cutThruAll()
|
||||
c = (cq.Workplane("XY").box(1, 1, 1).faces(">Z").workplane()
|
||||
.circle(0.25).cutThruAll())
|
||||
|
||||
# 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.
|
||||
|
||||
@ -4,37 +4,37 @@ import cadquery as cq
|
||||
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
|
||||
defaultSweep = cq.Workplane("YZ").workplane(offset=-10.0).circle(2.0). \
|
||||
workplane(offset=10.0).circle(1.0). \
|
||||
workplane(offset=10.0).circle(2.0).sweep(path, multisection=True)
|
||||
defaultSweep = (cq.Workplane("YZ").workplane(offset=-10.0).circle(2.0).
|
||||
workplane(offset=10.0).circle(1.0).
|
||||
workplane(offset=10.0).circle(2.0).sweep(path, multisection=True))
|
||||
|
||||
# We can sweep thrue different shapes
|
||||
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).rect(2.0, 2.0).sweep(path, multisection=True)
|
||||
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).rect(2.0, 2.0).sweep(path, multisection=True))
|
||||
|
||||
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).circle(1.0).sweep(path, multisection=True)
|
||||
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).circle(1.0).sweep(path, multisection=True))
|
||||
|
||||
|
||||
# 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). \
|
||||
sweep(path, multisection=True)
|
||||
specialSweep = (cq.Workplane("YZ").circle(1.0).workplane(offset=10.0).rect(2.0, 2.0).
|
||||
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
|
||||
path = cq.Workplane("XZ").moveTo(-5, 4).lineTo(0, 4). \
|
||||
threePointArc((4, 0), (0, -4)).lineTo(-5, -4)
|
||||
path = (cq.Workplane("XZ").moveTo(-5, 4).lineTo(0, 4).
|
||||
threePointArc((4, 0), (0, -4)).lineTo(-5, -4))
|
||||
|
||||
# Placement of different shapes should follow the path
|
||||
# cylinder r=1.5 along first line
|
||||
# then sweep allong arc from r=1.5 to r=1.0
|
||||
# then cylinder r=1.0 along last line
|
||||
arcSweep = cq.Workplane("YZ").workplane(offset=-5).moveTo(0, 4).circle(1.5). \
|
||||
workplane(offset=5).circle(1.5). \
|
||||
moveTo(0, -8).circle(1.0). \
|
||||
workplane(offset=-5).circle(1.0). \
|
||||
sweep(path, multisection=True)
|
||||
arcSweep = (cq.Workplane("YZ").workplane(offset=-5).moveTo(0, 4).circle(1.5).
|
||||
workplane(offset=5).circle(1.5).
|
||||
moveTo(0, -8).circle(1.0).
|
||||
workplane(offset=-5).circle(1.0).
|
||||
sweep(path, multisection=True))
|
||||
|
||||
|
||||
# Translate the resulting solids so that they do not overlap and display them left to right
|
||||
|
||||
@ -32,23 +32,23 @@ s = cq.Workplane("XY").box(total_length, total_width, height)
|
||||
s = s.faces("<Z").shell(-1.0 * t)
|
||||
|
||||
# make the bumps on the top
|
||||
s = s.faces(">Z").workplane(). \
|
||||
rarray(pitch, pitch, lbumps, wbumps, True).circle(bumpDiam / 2.0) \
|
||||
.extrude(bumpHeight)
|
||||
s = (s.faces(">Z").workplane().
|
||||
rarray(pitch, pitch, lbumps, wbumps, True).circle(bumpDiam / 2.0)
|
||||
.extrude(bumpHeight))
|
||||
|
||||
# add posts on the bottom. posts are different diameter depending on geometry
|
||||
# solid studs for 1 bump, tubes for multiple, none for 1x1
|
||||
tmp = s.faces("<Z").workplane(invert=True)
|
||||
|
||||
if lbumps > 1 and wbumps > 1:
|
||||
tmp = tmp.rarray(pitch, pitch, lbumps - 1, wbumps - 1, center=True). \
|
||||
circle(postDiam / 2.0).circle(bumpDiam / 2.0).extrude(height - t)
|
||||
tmp = (tmp.rarray(pitch, pitch, lbumps - 1, wbumps - 1, center=True).
|
||||
circle(postDiam / 2.0).circle(bumpDiam / 2.0).extrude(height - t))
|
||||
elif lbumps > 1:
|
||||
tmp = tmp.rarray(pitch, pitch, lbumps - 1, 1, center=True). \
|
||||
circle(t).extrude(height - t)
|
||||
tmp = (tmp.rarray(pitch, pitch, lbumps - 1, 1, center=True).
|
||||
circle(t).extrude(height - t))
|
||||
elif wbumps > 1:
|
||||
tmp = tmp.rarray(pitch, pitch, 1, wbumps - 1, center=True). \
|
||||
circle(t).extrude(height - t)
|
||||
tmp = (tmp.rarray(pitch, pitch, 1, wbumps - 1, center=True).
|
||||
circle(t).extrude(height - t))
|
||||
else:
|
||||
tmp = s
|
||||
|
||||
|
||||
Reference in New Issue
Block a user