Skip to content

Commit 8ea37a7

Browse files
sketch offset docs update (#1631)
1 parent dde33e3 commit 8ea37a7

File tree

1 file changed

+53
-22
lines changed

1 file changed

+53
-22
lines changed

doc/sketch.rst

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ Supported operations include :meth:`~cadquery.Workplane.extrude`,
193193
Sketches can be created as separate entities and reused, but also created ad-hoc
194194
in one fluent chain of calls as shown below.
195195

196-
197-
Note that the sketch is placed on all locations that are on the top of the stack.
196+
Sketches in-place
197+
=================
198198

199199
Constructing sketches in-place can be accomplished as follows.
200200

@@ -218,8 +218,35 @@ Constructing sketches in-place can be accomplished as follows.
218218

219219
Sketch API is available after the :meth:`~cadquery.Workplane.sketch` call and original `workplane`.
220220

221+
Placing an existing sketch on a workplane
222+
=========================================
223+
224+
Sometimes it is desired to place an existing sketches as-is on a workplane. This can be done with :meth:`~cadquery.Workplane.placeSketch`
225+
226+
.. cadquery::
227+
:height: 600px
228+
229+
import cadquery as cq
230+
231+
s = cq.Sketch().trapezoid(3, 1, 110).vertices().fillet(0.2)
232+
233+
result = (
234+
cq.Workplane()
235+
.box(5, 5, 5)
236+
.faces(">X")
237+
.workplane()
238+
.transformed((0, 0, -90))
239+
.placeSketch(s)
240+
.cutThruAll()
241+
)
242+
243+
Sketches spanning multiple elements
244+
===================================
245+
221246
When multiple elements are selected before constructing the sketch, multiple sketches will be created.
222247

248+
Note that the sketch is placed on all locations that are on the top of the stack.
249+
223250
.. cadquery::
224251
:height: 600px
225252

@@ -244,27 +271,10 @@ When multiple elements are selected before constructing the sketch, multiple ske
244271
.cutBlind(-0.5, taper=10)
245272
)
246273

247-
Sometimes it is desired to reuse existing sketches and place them as-is on a workplane.
248-
274+
Lofting between two sketches
275+
============================
249276

250-
.. cadquery::
251-
:height: 600px
252-
253-
import cadquery as cq
254-
255-
s = cq.Sketch().trapezoid(3, 1, 110).vertices().fillet(0.2)
256-
257-
result = (
258-
cq.Workplane()
259-
.box(5, 5, 5)
260-
.faces(">X")
261-
.workplane()
262-
.transformed((0, 0, -90))
263-
.placeSketch(s)
264-
.cutThruAll()
265-
)
266-
267-
Reusing of existing sketches is needed when using :meth:`~cadquery.Workplane.loft`.
277+
Two sketches on different workplanes are needed when using :meth:`~cadquery.Workplane.loft`.
268278

269279
.. cadquery::
270280
:height: 600px
@@ -278,3 +288,24 @@ Reusing of existing sketches is needed when using :meth:`~cadquery.Workplane.lof
278288
result = Workplane().placeSketch(s1, s2.moved(Location(Vector(0, 0, 3)))).loft()
279289

280290
When lofting only outer wires are taken into account and inner wires are silently ignored. Note that only sketches on the top of stack are considered for the current operation (i.e. there are no pending sketches), so when lofting or sweeping all relevant sketches have to be added in one `placeSketch` call.
291+
292+
Offsets made easy
293+
=================
294+
295+
Conveniently, it is possible to reuse a sketch to create an :meth:`~cadquery.Sketch.offset` shape.
296+
297+
.. cadquery::
298+
:height: 600px
299+
300+
import cadquery as cq
301+
302+
sketch = (cq.Sketch()
303+
.rect(1.0, 4.0)
304+
.circle(1.0)
305+
.clean()
306+
)
307+
308+
sketch_offset = sketch.copy().wires().offset(0.25)
309+
310+
result = cq.Workplane("front").placeSketch(sketch_offset).extrude(1.0)
311+
result = result.faces(">Z").workplane().placeSketch(sketch).cutBlind(-0.50)

0 commit comments

Comments
 (0)