You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/examples.rst
+54-54Lines changed: 54 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,8 +58,8 @@ Plate with Hole
58
58
59
59
A rectangular box, but with a hole added.
60
60
61
-
"\>Z" selects the top most face of the resulting box. The hole is located in the center because the default origin
62
-
of a working plane is at the center of the face. The default hole depth is through the entire part.
61
+
"\>Z" selects the top most face of the resulting box. The hole is located in the center because the default origin
62
+
of a working plane is at the center of the face. The default hole depth is through the entire part.
63
63
64
64
.. cadquery::
65
65
@@ -109,7 +109,7 @@ By default, rectangles and circles are centered around the previous working poin
109
109
Building Profiles using lines and arcs
110
110
--------------------------------------
111
111
112
-
Sometimes you need to build complex profiles using lines and arcs. This example builds a prismatic
112
+
Sometimes you need to build complex profiles using lines and arcs. This example builds a prismatic
113
113
solid from 2-d operations.
114
114
115
115
2-d operations maintain a current point, which is initially at the origin. Use close() to finish a
@@ -144,10 +144,10 @@ A new work plane center can be established at any point.
144
144
145
145
.. cadquery::
146
146
147
-
result = cq.Workplane("front").circle(3.0) #current point is the center of the circle, at (0, 0)
148
-
result = result.center(1.5, 0.0).rect(0.5, 0.5) # new work center is (1.5, 0.0)
147
+
result = cq.Workplane("front").circle(3.0) # current point is the center of the circle, at (0, 0)
148
+
result = result.center(1.5, 0.0).rect(0.5, 0.5) # new work center is (1.5, 0.0)
149
149
150
-
result = result.center(-1.5, 1.5).circle(0.25) # new work center is (0.0, 1.5).
150
+
result = result.center(-1.5, 1.5).circle(0.25) # new work center is (0.0, 1.5).
151
151
# The new center is specified relative to the previous center, not global coordinates!
152
152
153
153
result = result.extrude(0.25)
@@ -219,7 +219,7 @@ This example uses a polyline to create one half of an i-beam shape, which is mir
219
219
220
220
.. cadquery::
221
221
222
-
(L,H,W,t) = (100.0, 20.0, 20.0, 1.0)
222
+
(L, H, W, t) = (100.0, 20.0, 20.0, 1.0)
223
223
pts = [
224
224
(0, H/2.0),
225
225
(W/2.0, H/2.0),
@@ -279,7 +279,7 @@ needs a complex profile
279
279
Mirroring Symmetric Geometry
280
280
-----------------------------
281
281
282
-
You can mirror 2-d geometry when your shape is symmetric. In this example we also
282
+
You can mirror 2-d geometry when your shape is symmetric. In this example we also
283
283
introduce horizontal and vertical lines, which make for slightly easier coding.
284
284
285
285
@@ -364,7 +364,7 @@ Mirroring 3D Objects
364
364
Mirroring From Faces
365
365
-----------------------------
366
366
367
-
This example shows how you can mirror about a selected face. It also shows how the resulting mirrored object can be unioned immediately with the referenced mirror geometry.
367
+
This example shows how you can mirror about a selected face. It also shows how the resulting mirrored object can be unioned immediately with the referenced mirror geometry.
368
368
369
369
.. cadquery::
370
370
@@ -396,7 +396,7 @@ Creating Workplanes on Faces
396
396
This example shows how to locate a new workplane on the face of a previously created feature.
397
397
398
398
.. note::
399
-
Using workplanes in this way are a key feature of CadQuery. Unlike a typical 3d scripting
399
+
Using workplanes in this way are a key feature of CadQuery. Unlike a typical 3d scripting
400
400
language, using work planes frees you from tracking the position of various features in
401
401
variables, and allows the model to adjust itself with removing redundant dimensions
402
402
@@ -410,7 +410,7 @@ through the centerOption argument of :py:meth:`Workplane.workplane`.
410
410
411
411
.. cadquery::
412
412
413
-
result = cq.Workplane("front").box(2,3, 0.5) # make a basic prism
413
+
result = cq.Workplane("front").box(2,3, 0.5) # make a basic prism
414
414
result = result.faces(">Z").workplane().hole(0.5) # find the top-most face and make a hole
415
415
416
416
.. topic:: Api References
@@ -486,7 +486,7 @@ An existing CQ object can copy a workplane from another CQ object.
486
486
487
487
.. cadquery::
488
488
489
-
result = (cq.Workplane("front").circle(1).extrude(10) # make a cylinder
489
+
result = (cq.Workplane("front").circle(1).extrude(10) # make a cylinder
490
490
# We want to make a second cylinder perpendicular to the first,
491
491
# but we have no face to base the workplane off
492
492
.copyWorkplane(
@@ -528,7 +528,7 @@ You can create a rotated work plane by specifying angles of rotation relative to
528
528
Using construction Geometry
529
529
---------------------------
530
530
531
-
You can draw shapes to use the vertices as points to locate other features. Features that are used to
531
+
You can draw shapes to use the vertices as points to locate other features. Features that are used to
532
532
locate other features, rather than to create them, are called ``Construction Geometry``
533
533
534
534
In the example below, a rectangle is drawn, and its vertices are used to locate a set of holes.
@@ -826,7 +826,7 @@ You can split an object using a workplane, and retain either or both halves
826
826
The Classic OCC Bottle
827
827
----------------------
828
828
829
-
CadQuery is based on the OpenCascade.org (OCC) modeling Kernel. Those who are familiar with OCC know about the
829
+
CadQuery is based on the OpenCascade.org (OCC) modeling Kernel. Those who are familiar with OCC know about the
830
830
famous 'bottle' example. `The bottle example in the OCCT online documentation <https://old.opencascade.com/doc/occt-7.5.0/overview/html/occt__tutorial.html>`_.
831
831
832
832
A pythonOCC version is listed `here <https://github.com/tpaviot/pythonocc-demos/blob/f3ea9b4f65a9dff482be04b153d4ce5ec2430e13/examples/core_classic_occ_bottle.py>`_.
@@ -872,24 +872,24 @@ A Parametric Enclosure
872
872
:height: 400px
873
873
874
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
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
878
878
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
882
882
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
886
886
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.
(lid, bottom) = box.faces(">Z").workplane(-p_thickness - p_lipHeight).split(keepTop=True, keepBottom=True).all() # splits into two solids
@@ -982,9 +982,9 @@ regarding the underside of the brick.
982
982
#####
983
983
# Inputs
984
984
######
985
-
lbumps = 6 # number of bumps long
986
-
wbumps = 2 # number of bumps wide
987
-
thin = True # True for thin, False for thick
985
+
lbumps = 6 # number of bumps long
986
+
wbumps = 2 # number of bumps wide
987
+
thin = True # True for thin, False for thick
988
988
989
989
#
990
990
# Lego Brick Constants-- these make a Lego brick a Lego :)
@@ -1230,35 +1230,35 @@ Panel With Various Connector Holes
1230
1230
1231
1231
h_sep = 60
1232
1232
for idx in range(4):
1233
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(157,210-idx*h_sep).moveTo(-23.5,0).circle(1.6).moveTo(23.5,0).circle(1.6).moveTo(-17.038896,-5.7).threePointArc((-19.44306,-4.70416),(-20.438896,-2.3)).lineTo(-21.25,2.3).threePointArc((-20.25416,4.70416),(-17.85,5.7)).lineTo(17.85,5.7).threePointArc((20.25416,4.70416),(21.25,2.3)).lineTo(20.438896,-2.3).threePointArc((19.44306,-4.70416),(17.038896,-5.7)).close().cutThruAll()
1233
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(157,210 - idx*h_sep).moveTo(-23.5,0).circle(1.6).moveTo(23.5,0).circle(1.6).moveTo(-17.038896,-5.7).threePointArc((-19.44306,-4.70416),(-20.438896,-2.3)).lineTo(-21.25,2.3).threePointArc((-20.25416,4.70416),(-17.85,5.7)).lineTo(17.85,5.7).threePointArc((20.25416,4.70416),(21.25,2.3)).lineTo(20.438896,-2.3).threePointArc((19.44306,-4.70416),(17.038896,-5.7)).close().cutThruAll()
1234
1234
1235
1235
for idx in range(4):
1236
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(157,-30-idx*h_sep).moveTo(-16.65,0).circle(1.6).moveTo(16.65,0).circle(1.6).moveTo(-10.1889,-5.7).threePointArc((-12.59306,-4.70416),(-13.5889,-2.3)).lineTo(-14.4,2.3).threePointArc((-13.40416,4.70416),(-11,5.7)).lineTo(11,5.7).threePointArc((13.40416,4.70416),(14.4,2.3)).lineTo(13.5889,-2.3).threePointArc((12.59306,-4.70416),(10.1889,-5.7)).close().cutThruAll()
1236
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(157,-30 - idx*h_sep).moveTo(-16.65,0).circle(1.6).moveTo(16.65,0).circle(1.6).moveTo(-10.1889,-5.7).threePointArc((-12.59306,-4.70416),(-13.5889,-2.3)).lineTo(-14.4,2.3).threePointArc((-13.40416,4.70416),(-11,5.7)).lineTo(11,5.7).threePointArc((13.40416,4.70416),(14.4,2.3)).lineTo(13.5889,-2.3).threePointArc((12.59306,-4.70416),(10.1889,-5.7)).close().cutThruAll()
1237
1237
1238
1238
h_sep4DB9 = 30
1239
1239
for idx in range(8):
1240
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(91,225-idx*h_sep4DB9).moveTo(-12.5,0).circle(1.6).moveTo(12.5,0).circle(1.6).moveTo(-6.038896,-5.7).threePointArc((-8.44306,-4.70416),(-9.438896,-2.3)).lineTo(-10.25,2.3).threePointArc((-9.25416,4.70416),(-6.85,5.7)).lineTo(6.85,5.7).threePointArc((9.25416,4.70416),(10.25,2.3)).lineTo(9.438896,-2.3).threePointArc((8.44306,-4.70416),(6.038896,-5.7)).close().cutThruAll()
1240
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(91,225 - idx*h_sep4DB9).moveTo(-12.5,0).circle(1.6).moveTo(12.5,0).circle(1.6).moveTo(-6.038896,-5.7).threePointArc((-8.44306,-4.70416),(-9.438896,-2.3)).lineTo(-10.25,2.3).threePointArc((-9.25416,4.70416),(-6.85,5.7)).lineTo(6.85,5.7).threePointArc((9.25416,4.70416),(10.25,2.3)).lineTo(9.438896,-2.3).threePointArc((8.44306,-4.70416),(6.038896,-5.7)).close().cutThruAll()
1241
1241
1242
1242
for idx in range(4):
1243
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(25,210-idx*h_sep).moveTo(-23.5,0).circle(1.6).moveTo(23.5,0).circle(1.6).moveTo(-17.038896,-5.7).threePointArc((-19.44306,-4.70416),(-20.438896,-2.3)).lineTo(-21.25,2.3).threePointArc((-20.25416,4.70416),(-17.85,5.7)).lineTo(17.85,5.7).threePointArc((20.25416,4.70416),(21.25,2.3)).lineTo(20.438896,-2.3).threePointArc((19.44306,-4.70416),(17.038896,-5.7)).close().cutThruAll()
1243
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(25,210 - idx*h_sep).moveTo(-23.5,0).circle(1.6).moveTo(23.5,0).circle(1.6).moveTo(-17.038896,-5.7).threePointArc((-19.44306,-4.70416),(-20.438896,-2.3)).lineTo(-21.25,2.3).threePointArc((-20.25416,4.70416),(-17.85,5.7)).lineTo(17.85,5.7).threePointArc((20.25416,4.70416),(21.25,2.3)).lineTo(20.438896,-2.3).threePointArc((19.44306,-4.70416),(17.038896,-5.7)).close().cutThruAll()
1244
1244
1245
1245
for idx in range(4):
1246
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(25,-30-idx*h_sep).moveTo(-16.65,0).circle(1.6).moveTo(16.65,0).circle(1.6).moveTo(-10.1889,-5.7).threePointArc((-12.59306,-4.70416),(-13.5889,-2.3)).lineTo(-14.4,2.3).threePointArc((-13.40416,4.70416),(-11,5.7)).lineTo(11,5.7).threePointArc((13.40416,4.70416),(14.4,2.3)).lineTo(13.5889,-2.3).threePointArc((12.59306,-4.70416),(10.1889,-5.7)).close().cutThruAll()
1246
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(25,-30 - idx*h_sep).moveTo(-16.65,0).circle(1.6).moveTo(16.65,0).circle(1.6).moveTo(-10.1889,-5.7).threePointArc((-12.59306,-4.70416),(-13.5889,-2.3)).lineTo(-14.4,2.3).threePointArc((-13.40416,4.70416),(-11,5.7)).lineTo(11,5.7).threePointArc((13.40416,4.70416),(14.4,2.3)).lineTo(13.5889,-2.3).threePointArc((12.59306,-4.70416),(10.1889,-5.7)).close().cutThruAll()
1247
1247
1248
1248
for idx in range(8):
1249
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-41,225-idx*h_sep4DB9).moveTo(-12.5,0).circle(1.6).moveTo(12.5,0).circle(1.6).moveTo(-6.038896,-5.7).threePointArc((-8.44306,-4.70416),(-9.438896,-2.3)).lineTo(-10.25,2.3).threePointArc((-9.25416,4.70416),(-6.85,5.7)).lineTo(6.85,5.7).threePointArc((9.25416,4.70416),(10.25,2.3)).lineTo(9.438896,-2.3).threePointArc((8.44306,-4.70416),(6.038896,-5.7)).close().cutThruAll()
1249
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-41,225 - idx*h_sep4DB9).moveTo(-12.5,0).circle(1.6).moveTo(12.5,0).circle(1.6).moveTo(-6.038896,-5.7).threePointArc((-8.44306,-4.70416),(-9.438896,-2.3)).lineTo(-10.25,2.3).threePointArc((-9.25416,4.70416),(-6.85,5.7)).lineTo(6.85,5.7).threePointArc((9.25416,4.70416),(10.25,2.3)).lineTo(9.438896,-2.3).threePointArc((8.44306,-4.70416),(6.038896,-5.7)).close().cutThruAll()
1250
1250
1251
1251
for idx in range(4):
1252
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-107,210-idx*h_sep).moveTo(-23.5,0).circle(1.6).moveTo(23.5,0).circle(1.6).moveTo(-17.038896,-5.7).threePointArc((-19.44306,-4.70416),(-20.438896,-2.3)).lineTo(-21.25,2.3).threePointArc((-20.25416,4.70416),(-17.85,5.7)).lineTo(17.85,5.7).threePointArc((20.25416,4.70416),(21.25,2.3)).lineTo(20.438896,-2.3).threePointArc((19.44306,-4.70416),(17.038896,-5.7)).close().cutThruAll()
1252
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-107,210 - idx*h_sep).moveTo(-23.5,0).circle(1.6).moveTo(23.5,0).circle(1.6).moveTo(-17.038896,-5.7).threePointArc((-19.44306,-4.70416),(-20.438896,-2.3)).lineTo(-21.25,2.3).threePointArc((-20.25416,4.70416),(-17.85,5.7)).lineTo(17.85,5.7).threePointArc((20.25416,4.70416),(21.25,2.3)).lineTo(20.438896,-2.3).threePointArc((19.44306,-4.70416),(17.038896,-5.7)).close().cutThruAll()
1253
1253
1254
1254
for idx in range(4):
1255
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-107,-30-idx*h_sep).circle(14).rect(24.7487,24.7487, forConstruction=True).vertices().hole(3.2).cutThruAll()
1255
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-107,-30 - idx*h_sep).circle(14).rect(24.7487,24.7487, forConstruction=True).vertices().hole(3.2).cutThruAll()
1256
1256
1257
1257
for idx in range(8):
1258
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-173,225-idx*h_sep4DB9).moveTo(-12.5,0).circle(1.6).moveTo(12.5,0).circle(1.6).moveTo(-6.038896,-5.7).threePointArc((-8.44306,-4.70416),(-9.438896,-2.3)).lineTo(-10.25,2.3).threePointArc((-9.25416,4.70416),(-6.85,5.7)).lineTo(6.85,5.7).threePointArc((9.25416,4.70416),(10.25,2.3)).lineTo(9.438896,-2.3).threePointArc((8.44306,-4.70416),(6.038896,-5.7)).close().cutThruAll()
1258
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-173,225 - idx*h_sep4DB9).moveTo(-12.5,0).circle(1.6).moveTo(12.5,0).circle(1.6).moveTo(-6.038896,-5.7).threePointArc((-8.44306,-4.70416),(-9.438896,-2.3)).lineTo(-10.25,2.3).threePointArc((-9.25416,4.70416),(-6.85,5.7)).lineTo(6.85,5.7).threePointArc((9.25416,4.70416),(10.25,2.3)).lineTo(9.438896,-2.3).threePointArc((8.44306,-4.70416),(6.038896,-5.7)).close().cutThruAll()
1259
1259
1260
1260
for idx in range(4):
1261
-
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-173,-30-idx*h_sep).moveTo(-2.9176,-5.3).threePointArc((-6.05,0),(-2.9176,5.3)).lineTo(2.9176,5.3).threePointArc((6.05,0),(2.9176,-5.3)).close().cutThruAll()
1261
+
result = result.workplane(offset=1, centerOption="CenterOfBoundBox").center(-173,-30 - idx*h_sep).moveTo(-2.9176,-5.3).threePointArc((-6.05,0),(-2.9176,5.3)).lineTo(2.9176,5.3).threePointArc((6.05,0),(2.9176,-5.3)).close().cutThruAll()
1262
1262
1263
1263
1264
1264
Cycloidal gear
@@ -1271,21 +1271,21 @@ This specific examples generates a helical cycloidal gear.
0 commit comments