Skip to content

Commit d6c41d7

Browse files
authored
Merge pull request #921 from CadQuery/sketch-docs
Slight improvement of the sketch tutorial
2 parents 2b08071 + e7bc699 commit d6c41d7

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

cadquery/sketch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
arc_point,
3636
)
3737

38-
Modes = Literal["a", "s", "i"]
38+
Modes = Literal["a", "s", "i", "c"] # add, subtract, intersect, construct
3939
Point = Union[Vector, Tuple[Real, Real]]
4040

4141
T = TypeVar("T", bound="Sketch")

doc/sketch.rst

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,38 @@ combining them using boolean operations.
2525
cq.Sketch()
2626
.trapezoid(4,3,90)
2727
.vertices()
28-
.circle(.5,mode='s')
28+
.circle(.5, mode='s')
2929
.reset()
3030
.vertices()
3131
.fillet(.25)
3232
.reset()
33-
.rarray(.6,1,5,1).slot(1.5,0.4,mode='s',angle=90)
33+
.rarray(.6,1,5,1).slot(1.5,0.4, mode='s', angle=90)
3434
)
3535

3636
Note that selectors are implemented, but selection has to be explicitly reset. Sketch
3737
class does not implement history and all modifications happen in-place.
3838

39+
Modes
40+
^^^^^
41+
42+
Every operation from the face API accepts a mode parameter to define how to combine the created object with existing ones. It can be fused (``mode='a'``), cut (``mode='s'``), intersected (``mode='i'``) or just stored for construction (``mode='c'``). In the last case, it is mandatory to specify a ``tag`` in order to be able to refer to the object later on. By default faces are fused together. Note the usage of the subtractive and additive modes in the example above. The additional two are demonstrated below.
43+
44+
.. cadquery::
45+
:height: 600px
46+
47+
result = (
48+
cq.Sketch()
49+
.rect(1, 2, mode='c', tag='base')
50+
.vertices(tag='base')
51+
.circle(.7)
52+
.reset()
53+
.edges('|Y', tag='base')
54+
.ellipse(1.2, 1, mode='i')
55+
.reset()
56+
.rect(2, 2, mode='i')
57+
.clean()
58+
)
59+
3960

4061
Edge-based API
4162
==============
@@ -62,6 +83,7 @@ If needed, one can construct sketches by placing individual edges.
6283
Once the construction is finished it has to be converted to the face-based representation
6384
using :meth:`~cadquery.Sketch.assemble`. Afterwards, face based operations can be applied.
6485

86+
6587
Convex hull
6688
===========
6789

@@ -269,4 +291,4 @@ Reusing of existing sketches is needed when using :meth:`~cadquery.Workplane.lof
269291
.loft()
270292
)
271293

272-
When lofting only outer wires are taken into account.
294+
When lofting only outer wires are taken into account and inner wires are silently ignored.

0 commit comments

Comments
 (0)