From e520738b0fc8418112853f8fc632c76a2765eae9 Mon Sep 17 00:00:00 2001 From: adam-urbanczyk Date: Thu, 18 Nov 2021 19:13:31 +0100 Subject: [PATCH 1/4] Explain modes --- doc/sketch.rst | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/sketch.rst b/doc/sketch.rst index 3db3543a9..57416b3fb 100644 --- a/doc/sketch.rst +++ b/doc/sketch.rst @@ -25,17 +25,38 @@ combining them using boolean operations. cq.Sketch() .trapezoid(4,3,90) .vertices() - .circle(.5,mode='s') + .circle(.5, mode='s') .reset() .vertices() .fillet(.25) .reset() - .rarray(.6,1,5,1).slot(1.5,0.4,mode='s',angle=90) + .rarray(.6,1,5,1).slot(1.5,0.4, mode='s', angle=90) ) Note that selectors are implemented, but selection has to be explicitly reset. Sketch class does not implement history and all modifications happen in-place. +Modes +^^^^^ + +Every operation from the face API accepts a mode parameter to defines 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 bale 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. + +.. cadquery:: + :height: 600px + + result = ( + cq.Sketch() + .rect(1, 2, mode='c', tag='base') + .vertices(tag='base') + .circle(.7) + .reset() + .edges('|Y', tag='base') + .ellipse(1.2, 1, mode='i') + .reset() + .rect(2, 2, mode='i') + .clean() + ) + Edge-based API ============== @@ -62,6 +83,7 @@ If needed, one can construct sketches by placing individual edges. Once the construction is finished it has to be converted to the face-based representation using :meth:`~cadquery.Sketch.assemble`. Afterwards, face based operations can be applied. + Convex hull =========== @@ -269,4 +291,4 @@ Reusing of existing sketches is needed when using :meth:`~cadquery.Workplane.lof .loft() ) -When lofting only outer wires are taken into account. +When lofting only outer wires are taken into account and inner wires are silently ignored. From bbb876b5055dc2431835dd920dc9fc2ec4558c20 Mon Sep 17 00:00:00 2001 From: adam-urbanczyk Date: Thu, 18 Nov 2021 19:14:39 +0100 Subject: [PATCH 2/4] Fix mode annotations --- cadquery/sketch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cadquery/sketch.py b/cadquery/sketch.py index 150f766cd..7feb711ba 100644 --- a/cadquery/sketch.py +++ b/cadquery/sketch.py @@ -35,7 +35,7 @@ arc_point, ) -Modes = Literal["a", "s", "i"] +Modes = Literal["a", "s", "i", "c"] # add, subtract, intersect, construct Point = Union[Vector, Tuple[Real, Real]] T = TypeVar("T", bound="Sketch") From 713bc41a7c2446523cbbe953611f3e2c04f37f73 Mon Sep 17 00:00:00 2001 From: AU Date: Thu, 18 Nov 2021 21:37:45 +0100 Subject: [PATCH 3/4] Typo fix --- doc/sketch.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sketch.rst b/doc/sketch.rst index 57416b3fb..5846e39e0 100644 --- a/doc/sketch.rst +++ b/doc/sketch.rst @@ -39,7 +39,7 @@ class does not implement history and all modifications happen in-place. Modes ^^^^^ -Every operation from the face API accepts a mode parameter to defines 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 bale 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. +Every operation from the face API accepts a mode parameter to defines 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. .. cadquery:: :height: 600px From e7bc6992ee1a7b87bffdb3db2498280ef9d07256 Mon Sep 17 00:00:00 2001 From: AU Date: Fri, 19 Nov 2021 18:43:44 +0100 Subject: [PATCH 4/4] Update doc/sketch.rst Co-authored-by: Jeremy Wright --- doc/sketch.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sketch.rst b/doc/sketch.rst index 5846e39e0..bed5d4732 100644 --- a/doc/sketch.rst +++ b/doc/sketch.rst @@ -39,7 +39,7 @@ class does not implement history and all modifications happen in-place. Modes ^^^^^ -Every operation from the face API accepts a mode parameter to defines 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. +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. .. cadquery:: :height: 600px