Skip to content

Commit 550f774

Browse files
authored
Fix inconsistent examples code style
1 parent b018d54 commit 550f774

File tree

1 file changed

+89
-89
lines changed

1 file changed

+89
-89
lines changed

doc/examples.rst

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ needs a complex profile
262262
(0.5, 1.0),
263263
(0, 1.0)
264264
]
265-
r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts,includeCurrent=True).close()
265+
r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts, includeCurrent=True).close()
266266
result = r.extrude(0.5)
267267

268268
.. topic:: Api References
@@ -285,9 +285,9 @@ introduce horizontal and vertical lines, which make for slightly easier coding.
285285

286286
.. cadquery::
287287

288-
r = cq.Workplane("front").hLine(1.0) # 1.0 is the distance, not coordinate
289-
r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0) # hLineTo allows using xCoordinate not distance
290-
result =r.mirrorY().extrude(0.25 ) # mirror the geometry and extrude
288+
r = cq.Workplane("front").hLine(1.0) # 1.0 is the distance, not coordinate
289+
r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0) # hLineTo allows using xCoordinate not distance
290+
result = r.mirrorY().extrude(0.25) # mirror the geometry and extrude
291291

292292
.. topic:: Api References
293293

@@ -308,34 +308,34 @@ Mirroring 3D Objects
308308
.. cadquery::
309309

310310
result0 = (cadquery.Workplane("XY")
311-
.moveTo(10,0)
312-
.lineTo(5,0)
313-
.threePointArc((3.9393,0.4393),(3.5,1.5))
314-
.threePointArc((3.0607,2.5607),(2,3))
315-
.lineTo(1.5,3)
316-
.threePointArc((0.4393,3.4393),(0,4.5))
317-
.lineTo(0,13.5)
318-
.threePointArc((0.4393,14.5607),(1.5,15))
319-
.lineTo(28,15)
320-
.lineTo(28,13.5)
321-
.lineTo(24,13.5)
322-
.lineTo(24,11.5)
323-
.lineTo(27,11.5)
324-
.lineTo(27,10)
325-
.lineTo(22,10)
326-
.lineTo(22,13.2)
327-
.lineTo(14.5,13.2)
328-
.lineTo(14.5,10)
329-
.lineTo(12.5,10 )
330-
.lineTo(12.5,13.2)
331-
.lineTo(5.5,13.2)
332-
.lineTo(5.5,2)
333-
.threePointArc((5.793,1.293),(6.5,1))
334-
.lineTo(10,1)
311+
.moveTo(10, 0)
312+
.lineTo(5, 0)
313+
.threePointArc((3.9393, 0.4393), (3.5, 1.5))
314+
.threePointArc((3.0607, 2.5607), (2, 3))
315+
.lineTo(1.5, 3)
316+
.threePointArc((0.4393, 3.4393), (0, 4.5))
317+
.lineTo(0, 13.5)
318+
.threePointArc((0.4393, 14.5607), (1.5, 15))
319+
.lineTo(28, 15)
320+
.lineTo(28, 13.5)
321+
.lineTo(24, 13.5)
322+
.lineTo(24, 11.5)
323+
.lineTo(27, 11.5)
324+
.lineTo(27, 10)
325+
.lineTo(22, 10)
326+
.lineTo(22, 13.2)
327+
.lineTo(14.5, 13.2)
328+
.lineTo(14.5, 10)
329+
.lineTo(12.5, 10)
330+
.lineTo(12.5, 13.2)
331+
.lineTo(5.5, 13.2)
332+
.lineTo(5.5, 2)
333+
.threePointArc((5.793, 1.293), (6.5, 1))
334+
.lineTo(10, 1)
335335
.close())
336336
result = result0.extrude(100)
337337

338-
result = result.rotate((0, 0, 0),(1, 0, 0), 90)
338+
result = result.rotate((0, 0, 0), (1, 0, 0), 90)
339339

340340
result = result.translate(result.val().BoundingBox().center.multiply(-1))
341341

@@ -465,9 +465,9 @@ This example uses an offset workplane to make a compound object, which is perfec
465465

466466
.. cadquery::
467467

468-
result = cq.Workplane("front").box(3, 2, 0.5) #make a basic prism
469-
result = result.faces("<X").workplane(offset=0.75) #workplane is offset from the object surface
470-
result = result.circle(1.0).extrude(0.5) #disc
468+
result = cq.Workplane("front").box(3, 2, 0.5) # make a basic prism
469+
result = result.faces("<X").workplane(offset=0.75) # workplane is offset from the object surface
470+
result = result.circle(1.0).extrude(0.5) # disc
471471

472472
.. topic:: Api References
473473

@@ -513,7 +513,7 @@ You can create a rotated work plane by specifying angles of rotation relative to
513513

514514
result = (cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").workplane()
515515
.transformed(offset=cq.Vector(0, -1.5, 1.0),rotate=cq.Vector(60, 0, 0))
516-
.rect(1.5,1.5,forConstruction=True).vertices().hole(0.25))
516+
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25))
517517

518518
.. topic:: Api References
519519

@@ -536,7 +536,7 @@ In the example below, a rectangle is drawn, and its vertices are used to locate
536536
.. cadquery::
537537

538538
result = (cq.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane()
539-
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125 ))
539+
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125))
540540

541541
.. topic:: Api References
542542

@@ -724,7 +724,7 @@ Here we fillet all of the edges of a simple plate.
724724

725725
.. cadquery::
726726

727-
result = cq.Workplane("XY" ).box(3, 3, 0.5).edges("|Z").fillet(0.125)
727+
result = cq.Workplane("XY").box(3, 3, 0.5).edges("|Z").fillet(0.125)
728728
729729
.. topic:: Api References
730730

@@ -791,11 +791,11 @@ with just a few lines of code.
791791

792792
.. cadquery::
793793

794-
(length,height,bearing_diam, thickness,padding) = ( 30.0, 40.0, 22.0, 10.0, 8.0)
794+
(length, height, bearing_diam, thickness, padding) = (30.0, 40.0, 22.0, 10.0, 8.0)
795795

796-
result = (cq.Workplane("XY").box(length,height,thickness).faces(">Z").workplane().hole(bearing_diam)
796+
result = (cq.Workplane("XY").box(length, height, thickness).faces(">Z").workplane().hole(bearing_diam)
797797
.faces(">Z").workplane()
798-
.rect(length-padding,height-padding,forConstruction=True)
798+
.rect(length-padding, height-padding, forConstruction=True)
799799
.vertices().cboreHole(2.4, 4.4, 2.1))
800800

801801

@@ -806,9 +806,9 @@ You can split an object using a workplane, and retain either or both halves
806806

807807
.. cadquery::
808808

809-
c = cq.Workplane("XY").box(1,1,1).faces(">Z").workplane().circle(0.25).cutThruAll()
809+
c = cq.Workplane("XY").box(1, 1, 1).faces(">Z").workplane().circle(0.25).cutThruAll()
810810

811-
#now cut it in half sideways
811+
# now cut it in half sideways
812812
result = c.faces(">Y").workplane(-0.5).split(keepTop=True)
813813

814814
.. topic:: Api References
@@ -837,18 +837,18 @@ ones at 13 lines, but that's very short compared to the pythonOCC version, which
837837

838838
.. cadquery::
839839

840-
(L,w,t) = (20.0, 6.0, 3.0)
840+
(L, w, t) = (20.0, 6.0, 3.0)
841841
s = cq.Workplane("XY")
842842

843843
# Draw half the profile of the bottle and extrude it
844844
p = (s.center(-L/2.0, 0).vLine(w/2.0)
845-
.threePointArc((L/2.0, w/2.0 + t),(L, w/2.0)).vLine(-w/2.0)
846-
.mirrorX().extrude(30.0,True))
845+
.threePointArc((L/2.0, w/2.0 + t), (L, w/2.0)).vLine(-w/2.0)
846+
.mirrorX().extrude(30.0, True))
847847

848-
#make the neck
849-
p = p.faces(">Z").workplane(centerOption="CenterOfMass").circle(3.0).extrude(2.0,True)
848+
# Make the neck
849+
p = p.faces(">Z").workplane(centerOption="CenterOfMass").circle(3.0).extrude(2.0, True)
850850

851-
#make a shell
851+
# Make a shell
852852
result = p.faces(">Z").shell(0.3)
853853

854854
.. topic:: Api References
@@ -871,80 +871,80 @@ A Parametric Enclosure
871871
.. cadquery::
872872
:height: 400px
873873

874-
#parameter definitions
875-
p_outerWidth = 100.0 #Outer width of box enclosure
876-
p_outerLength = 150.0 #Outer length of box enclosure
877-
p_outerHeight = 50.0 #Outer height of box enclosure
874+
# parameter definitions
875+
p_outerWidth = 100.0 # Outer width of box enclosure
876+
p_outerLength = 150.0 # Outer length of box enclosure
877+
p_outerHeight = 50.0 # Outer height of box enclosure
878878

879-
p_thickness = 3.0 #Thickness of the box walls
880-
p_sideRadius = 10.0 #Radius for the curves around the sides of the box
881-
p_topAndBottomRadius = 2.0 #Radius for the curves on the top and bottom edges of the box
879+
p_thickness = 3.0 # Thickness of the box walls
880+
p_sideRadius = 10.0 # Radius for the curves around the sides of the box
881+
p_topAndBottomRadius = 2.0 # Radius for the curves on the top and bottom edges of the box
882882

883-
p_screwpostInset = 12.0 #How far in from the edges the screw posts should be place.
884-
p_screwpostID = 4.0 #Inner Diameter of the screw post holes, should be roughly screw diameter not including threads
885-
p_screwpostOD = 10.0 #Outer Diameter of the screw posts.\nDetermines overall thickness of the posts
883+
p_screwpostInset = 12.0 # How far in from the edges the screw posts should be place.
884+
p_screwpostID = 4.0 # Inner Diameter of the screw post holes, should be roughly screw diameter not including threads
885+
p_screwpostOD = 10.0 # Outer Diameter of the screw posts.\nDetermines overall thickness of the posts
886886

887-
p_boreDiameter = 8.0 #Diameter of the counterbore hole, if any
888-
p_boreDepth = 1.0 #Depth of the counterbore hole, if
889-
p_countersinkDiameter = 0.0 #Outer diameter of countersink. Should roughly match the outer diameter of the screw head
890-
p_countersinkAngle = 90.0 #Countersink angle (complete angle between opposite sides, not from center to one side)
891-
p_flipLid = True #Whether to place the lid with the top facing down or not.
892-
p_lipHeight = 1.0 #Height of lip on the underside of the lid.\nSits inside the box body for a snug fit.
887+
p_boreDiameter = 8.0 # Diameter of the counterbore hole, if any
888+
p_boreDepth = 1.0 # Depth of the counterbore hole, if
889+
p_countersinkDiameter = 0.0 # Outer diameter of countersink. Should roughly match the outer diameter of the screw head
890+
p_countersinkAngle = 90.0 # Countersink angle (complete angle between opposite sides, not from center to one side)
891+
p_flipLid = True # Whether to place the lid with the top facing down or not.
892+
p_lipHeight = 1.0 # Height of lip on the underside of the lid.\nSits inside the box body for a snug fit.
893893

894-
#outer shell
895-
oshell = cq.Workplane("XY").rect(p_outerWidth,p_outerLength).extrude(p_outerHeight + p_lipHeight)
894+
# outer shell
895+
oshell = cq.Workplane("XY").rect(p_outerWidth, p_outerLength).extrude(p_outerHeight + p_lipHeight)
896896

897-
#weird geometry happens if we make the fillets in the wrong order
897+
# weird geometry happens if we make the fillets in the wrong order
898898
if p_sideRadius > p_topAndBottomRadius:
899899
oshell = oshell.edges("|Z").fillet(p_sideRadius)
900900
oshell = oshell.edges("#Z").fillet(p_topAndBottomRadius)
901901
else:
902902
oshell = oshell.edges("#Z").fillet(p_topAndBottomRadius)
903903
oshell = oshell.edges("|Z").fillet(p_sideRadius)
904904
905-
#inner shell
906-
ishell = (oshell.faces("<Z").workplane(p_thickness,True)
907-
.rect((p_outerWidth - 2.0* p_thickness),(p_outerLength - 2.0*p_thickness))
908-
.extrude((p_outerHeight - 2.0*p_thickness),False) #set combine false to produce just the new boss
905+
# inner shell
906+
ishell = (oshell.faces("<Z").workplane(p_thickness, True)
907+
.rect((p_outerWidth - 2.0*p_thickness), (p_outerLength - 2.0*p_thickness))
908+
.extrude((p_outerHeight - 2.0*p_thickness), False) # set combine false to produce just the new boss
909909
)
910910
ishell = ishell.edges("|Z").fillet(p_sideRadius - p_thickness)
911911
912-
#make the box outer box
912+
# make the box outer box
913913
box = oshell.cut(ishell)
914914

915-
#make the screw posts
915+
# make the screw posts
916916
POSTWIDTH = (p_outerWidth - 2.0*p_screwpostInset)
917-
POSTLENGTH = (p_outerLength -2.0*p_screwpostInset)
917+
POSTLENGTH = (p_outerLength - 2.0*p_screwpostInset)
918918

919919
box = (box.faces(">Z").workplane(-p_thickness)
920-
.rect(POSTWIDTH,POSTLENGTH,forConstruction=True)
920+
.rect(POSTWIDTH, POSTLENGTH, forConstruction=True)
921921
.vertices().circle(p_screwpostOD/2.0).circle(p_screwpostID/2.0)
922-
.extrude((-1.0)*(p_outerHeight + p_lipHeight -p_thickness ),True))
922+
.extrude((-1.0)*(p_outerHeight + p_lipHeight - p_thickness),True))
923923

924-
#split lid into top and bottom parts
925-
(lid,bottom) = box.faces(">Z").workplane(-p_thickness -p_lipHeight ).split(keepTop=True,keepBottom=True).all() #splits into two solids
924+
# split lid into top and bottom parts
925+
(lid, bottom) = box.faces(">Z").workplane(-p_thickness - p_lipHeight).split(keepTop=True, keepBottom=True).all() # splits into two solids
926926

927-
#translate the lid, and subtract the bottom from it to produce the lid inset
928-
lowerLid = lid.translate((0,0,-p_lipHeight))
929-
cutlip = lowerLid.cut(bottom).translate((p_outerWidth + p_thickness ,0,p_thickness - p_outerHeight + p_lipHeight))
927+
# translate the lid, and subtract the bottom from it to produce the lid inset
928+
lowerLid = lid.translate((0, 0, -p_lipHeight))
929+
cutlip = lowerLid.cut(bottom).translate((p_outerWidth + p_thickness, 0, p_thickness - p_outerHeight + p_lipHeight))
930930

931-
#compute centers for counterbore/countersink or counterbore
932-
topOfLidCenters = cutlip.faces(">Z").workplane().rect(POSTWIDTH,POSTLENGTH,forConstruction=True).vertices()
931+
# compute centers for counterbore/countersink or counterbore
932+
topOfLidCenters = cutlip.faces(">Z").workplane().rect(POSTWIDTH, POSTLENGTH, forConstruction=True).vertices()
933933

934-
#add holes of the desired type
934+
# add holes of the desired type
935935
if p_boreDiameter > 0 and p_boreDepth > 0:
936-
topOfLid = topOfLidCenters.cboreHole(p_screwpostID,p_boreDiameter,p_boreDepth,(2.0)*p_thickness)
936+
topOfLid = topOfLidCenters.cboreHole(p_screwpostID, p_boreDiameter, p_boreDepth, 2.0*p_thickness)
937937
elif p_countersinkDiameter > 0 and p_countersinkAngle > 0:
938-
topOfLid = topOfLidCenters.cskHole(p_screwpostID,p_countersinkDiameter,p_countersinkAngle,(2.0)*p_thickness)
938+
topOfLid = topOfLidCenters.cskHole(p_screwpostID, p_countersinkDiameter, p_countersinkAngle, 2.0*p_thickness)
939939
else:
940-
topOfLid= topOfLidCenters.hole(p_screwpostID,(2.0)*p_thickness)
940+
topOfLid = topOfLidCenters.hole(p_screwpostID, 2.0*p_thickness)
941941

942-
#flip lid upside down if desired
942+
# flip lid upside down if desired
943943
if p_flipLid:
944-
topOfLid = topOfLid.rotateAboutCenter((1,0,0),180)
944+
topOfLid = topOfLid.rotateAboutCenter((1, 0, 0), 180)
945945

946-
#return the combined result
947-
result =topOfLid.union(bottom)
946+
# return the combined result
947+
result = topOfLid.union(bottom)
948948

949949

950950
.. topic:: Api References

0 commit comments

Comments
 (0)