mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Fixing examples, PR #910
This commit is contained in:
parent
bc2c06ba52
commit
aeb6b32b65
10 changed files with 83 additions and 67 deletions
|
|
@ -21,7 +21,7 @@ The dimensions of the Lego block follow. A key parameter is ``pip_count``, the l
|
|||
of the Lego blocks in pips. This parameter must be at least 2.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 29, 32-45
|
||||
:lines: 30,31, 34-47
|
||||
|
||||
********************
|
||||
Step 2: Part Builder
|
||||
|
|
@ -31,7 +31,7 @@ The Lego block will be created by the ``BuildPart`` builder as it's a discrete t
|
|||
dimensional part; therefore, we'll instantiate a ``BuildPart`` with the name ``lego``.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47
|
||||
:lines: 49
|
||||
|
||||
**********************
|
||||
Step 3: Sketch Builder
|
||||
|
|
@ -43,7 +43,7 @@ object. As this sketch will be part of the lego part, we'll create a sketch bui
|
|||
in the context of the part builder as follows:
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-49
|
||||
:lines: 49-51
|
||||
:emphasize-lines: 3
|
||||
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ of the Lego block. The following step is going to refer to this rectangle, so it
|
|||
be assigned the identifier ``perimeter``.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51
|
||||
:lines: 49-53
|
||||
:emphasize-lines: 5
|
||||
|
||||
Once the ``Rectangle`` object is created the sketch appears as follows:
|
||||
|
|
@ -76,7 +76,7 @@ hollowed out. This will be done with the ``Offset`` operation which is going to
|
|||
create a new object from ``perimeter``.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61
|
||||
:lines: 49-53,58-64
|
||||
:emphasize-lines: 7-12
|
||||
|
||||
The first parameter to ``Offset`` is the reference object. The ``amount`` is a
|
||||
|
|
@ -104,7 +104,7 @@ objects are in the scope of a location context (``GridLocations`` in this case)
|
|||
that defined multiple points, multiple rectangles are created.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61,65-69
|
||||
:lines: 49-53,58-64,69-73
|
||||
:emphasize-lines: 13-17
|
||||
|
||||
Here we can see that the first ``GridLocations`` creates two positions which causes
|
||||
|
|
@ -125,8 +125,8 @@ To convert the internal grid to ridges, the center needs to be removed. This wil
|
|||
with another ``Rectangle``.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61,65-69,74-78
|
||||
:emphasize-lines: 17-22
|
||||
:lines: 49-53,58-64,69-73,78-83
|
||||
:emphasize-lines: 18-23
|
||||
|
||||
The ``Rectangle`` is subtracted from the sketch to leave the ridges as follows:
|
||||
|
||||
|
|
@ -142,8 +142,8 @@ Lego blocks use a set of internal hollow cylinders that the pips push against
|
|||
to hold two blocks together. These will be created with ``Circle``.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61,65-69,74-76,82-87
|
||||
:emphasize-lines: 21-26
|
||||
:lines: 49-53,58-64,69-73,78-83,88-93
|
||||
:emphasize-lines: 24-29
|
||||
|
||||
Here another ``GridLocations`` is used to position the centers of the circles. Note
|
||||
that since both ``Circle`` objects are in the scope of the location context, both
|
||||
|
|
@ -162,8 +162,8 @@ Now that the sketch is complete it needs to be extruded into the three dimension
|
|||
wall object.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61,65-69,74-76,82-87,91-92
|
||||
:emphasize-lines: 27-28
|
||||
:lines: 49-53,58-64,69-73,78-83,88-93,98-99
|
||||
:emphasize-lines: 30-31
|
||||
|
||||
Note how the ``Extrude`` operation is no longer in the ``BuildSketch`` scope and has returned
|
||||
back into the ``BuildPart`` scope. This causes ``BuildSketch`` to exit and transfer the
|
||||
|
|
@ -183,8 +183,8 @@ Now that the walls are complete, the top of the block needs to be added. Althoug
|
|||
could be done with another sketch, we'll add a box to the top of the walls.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61,65-69,74-76,82-87,91-92,100-108
|
||||
:emphasize-lines: 29-37
|
||||
:lines: 49-53,58-64,69-73,78-83,88-93,98-99,110-118
|
||||
:emphasize-lines: 32-40
|
||||
|
||||
To position the top, we'll describe the top center of the lego walls with a ``Locations`` context.
|
||||
To determine the height we'll extract that from the
|
||||
|
|
@ -211,8 +211,8 @@ The final step is to add the pips to the top of the Lego block. To do this we'll
|
|||
a new workplane on top of the block where we can position the pips.
|
||||
|
||||
.. literalinclude:: ../examples/lego.py
|
||||
:lines: 47-51,55-61,65-69,74-76,82-87,91-92,100-108,116-124
|
||||
:emphasize-lines: 38-46
|
||||
:lines: 49-53,58-64,69-73,78-83,88-93,98-99,110-118,129-137
|
||||
:emphasize-lines: 41-49
|
||||
|
||||
In this case, the workplane is created from the top Face of the Lego block by using the
|
||||
``faces`` method and then sorted vertically and taking the top one ``sort_by(Axis.Z)[-1]``.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue