mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-07 11:10:48 -08:00
adapted to new file structure and lower cas functions
This commit is contained in:
parent
981f44b01e
commit
707890845a
5 changed files with 872 additions and 49 deletions
|
|
@ -57,23 +57,23 @@ There are several objects and operations that apply to more than one type
|
||||||
of builder which are listed here. The builder that these operations apply
|
of builder which are listed here. The builder that these operations apply
|
||||||
to is determined by context.
|
to is determined by context.
|
||||||
|
|
||||||
.. py:module:: build_generic
|
.. py:module:: operations_generic
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Objects
|
Objects
|
||||||
=======
|
=======
|
||||||
.. autoclass:: Add
|
.. autoclass:: add
|
||||||
|
|
||||||
==========
|
==========
|
||||||
Operations
|
Operations
|
||||||
==========
|
==========
|
||||||
.. autoclass:: BoundingBox
|
.. autoclass:: bounding_box
|
||||||
.. autoclass:: Chamfer
|
.. autoclass:: chamfer
|
||||||
.. autoclass:: Fillet
|
.. autoclass:: fillet
|
||||||
.. autoclass:: Mirror
|
.. autoclass:: mirror
|
||||||
.. autoclass:: Offset
|
.. autoclass:: offset
|
||||||
.. autoclass:: Scale
|
.. autoclass:: scale
|
||||||
.. autoclass:: Split
|
.. autoclass:: split
|
||||||
|
|
||||||
*********
|
*********
|
||||||
BuildLine
|
BuildLine
|
||||||
|
|
@ -83,6 +83,8 @@ BuildLine
|
||||||
.. autoclass:: BuildLine
|
.. autoclass:: BuildLine
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
.. py:module:: objects_curve
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Objects
|
Objects
|
||||||
=======
|
=======
|
||||||
|
|
@ -109,6 +111,8 @@ BuildSketch
|
||||||
.. autoclass:: BuildSketch
|
.. autoclass:: BuildSketch
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
.. py:module:: objects_sketch
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Objects
|
Objects
|
||||||
=======
|
=======
|
||||||
|
|
@ -125,11 +129,13 @@ Objects
|
||||||
.. autoclass:: Text
|
.. autoclass:: Text
|
||||||
.. autoclass:: Trapezoid
|
.. autoclass:: Trapezoid
|
||||||
|
|
||||||
|
.. py:module:: operations_sketch
|
||||||
|
|
||||||
==========
|
==========
|
||||||
Operations
|
Operations
|
||||||
==========
|
==========
|
||||||
.. autoclass:: MakeFace
|
.. autoclass:: make_face
|
||||||
.. autoclass:: MakeHull
|
.. autoclass:: make_hull
|
||||||
|
|
||||||
*********
|
*********
|
||||||
BuildPart
|
BuildPart
|
||||||
|
|
@ -140,6 +146,8 @@ BuildPart
|
||||||
.. autoclass:: BuildPart
|
.. autoclass:: BuildPart
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
.. py:module:: objects_part
|
||||||
|
|
||||||
=======
|
=======
|
||||||
Objects
|
Objects
|
||||||
=======
|
=======
|
||||||
|
|
@ -149,15 +157,17 @@ Objects
|
||||||
.. autoclass:: Sphere
|
.. autoclass:: Sphere
|
||||||
.. autoclass:: Torus
|
.. autoclass:: Torus
|
||||||
.. autoclass:: Wedge
|
.. autoclass:: Wedge
|
||||||
|
.. autoclass:: CounterBoreHole
|
||||||
|
.. autoclass:: CounterSinkHole
|
||||||
|
.. autoclass:: Hole
|
||||||
|
|
||||||
|
.. py:module:: operations_part
|
||||||
|
|
||||||
==========
|
==========
|
||||||
Operations
|
Operations
|
||||||
==========
|
==========
|
||||||
.. autoclass:: CounterBoreHole
|
.. autoclass:: extrude
|
||||||
.. autoclass:: CounterSinkHole
|
.. autoclass:: loft
|
||||||
.. autoclass:: Extrude
|
.. autoclass:: revolve
|
||||||
.. autoclass:: Hole
|
.. autoclass:: section
|
||||||
.. autoclass:: Loft
|
.. autoclass:: sweep
|
||||||
.. autoclass:: Revolve
|
|
||||||
.. autoclass:: Section
|
|
||||||
.. autoclass:: Sweep
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ CAD objects described in the following section are frequently of these types.
|
||||||
.. autoclass:: BoundBox
|
.. autoclass:: BoundBox
|
||||||
.. autoclass:: Color
|
.. autoclass:: Color
|
||||||
.. autoclass:: Location
|
.. autoclass:: Location
|
||||||
|
.. autoclass:: Pos
|
||||||
|
.. autoclass:: Rot
|
||||||
.. autoclass:: Matrix
|
.. autoclass:: Matrix
|
||||||
.. autoclass:: Plane
|
.. autoclass:: Plane
|
||||||
.. autoclass:: Rotation
|
.. autoclass:: Rotation
|
||||||
|
|
|
||||||
809
docs/general_examples_algebra.py
Normal file
809
docs/general_examples_algebra.py
Normal file
|
|
@ -0,0 +1,809 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
name: general_examples_algebra.py
|
||||||
|
by: Bernhard Walter
|
||||||
|
date: March 2023
|
||||||
|
|
||||||
|
desc:
|
||||||
|
|
||||||
|
This is the build123d general examples python script. It generates the SVGs
|
||||||
|
when run as a script, and is pulled into sphinx docs by
|
||||||
|
tutorial_general.rst.
|
||||||
|
|
||||||
|
license:
|
||||||
|
|
||||||
|
Copyright 2022 jdegenstein
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
"""
|
||||||
|
from build123d import *
|
||||||
|
|
||||||
|
svg_opts = {
|
||||||
|
"width": 500,
|
||||||
|
"height": 300,
|
||||||
|
"pixel_scale": 4,
|
||||||
|
"margin_left": 10,
|
||||||
|
"margin_top": 10,
|
||||||
|
"show_axes": False,
|
||||||
|
"show_hidden": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def svgout(ex_counter):
|
||||||
|
exec(
|
||||||
|
f"""
|
||||||
|
ex{ex_counter}.export_svg(
|
||||||
|
f"assets/general_ex{ex_counter}_algebra.svg",
|
||||||
|
(-100, -100, 70),
|
||||||
|
(0, 0, 1),
|
||||||
|
svg_opts=svg_opts,
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
ex_counter = 1
|
||||||
|
##########################################
|
||||||
|
# 1. Simple Rectangular Plate
|
||||||
|
# [Ex. 1]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex1 = Box(length, width, thickness)
|
||||||
|
# [Ex. 1]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex1.part)
|
||||||
|
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 2. Plane with hole
|
||||||
|
# [Ex. 2]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
center_hole_dia = 22.0
|
||||||
|
|
||||||
|
ex2 = Box(length, width, thickness)
|
||||||
|
ex2 -= Cylinder(radius=center_hole_dia / 2, height=thickness)
|
||||||
|
# [Ex. 2]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
# show_object(ex2.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 3. An extruded prismatic solid
|
||||||
|
# [Ex. 3]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
sk3 = Circle(width) - Rectangle(length / 2, width / 2)
|
||||||
|
ex3 = extrude(sk3, amount=2 * thickness)
|
||||||
|
# [Ex. 3]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
# show_object(ex3.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# Building profiles using lines and arcs
|
||||||
|
# [Ex. 4]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
lines = Curve() + [
|
||||||
|
Line((0, 0), (length, 0)),
|
||||||
|
Line((length, 0), (length, width)),
|
||||||
|
ThreePointArc((length, width), (width, width * 1.5), (0.0, width)),
|
||||||
|
Line((0.0, width), (0, 0)),
|
||||||
|
]
|
||||||
|
sk4 = make_face(lines)
|
||||||
|
ex4 = extrude(sk4, amount=thickness)
|
||||||
|
# [Ex. 4]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
# show_object(ex4.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# Moving the current working point
|
||||||
|
# [Ex. 5]
|
||||||
|
a, b, c, d = 90, 45, 15, 7.5
|
||||||
|
|
||||||
|
sk5 = Circle(a) - Pos(b, 0.0) * Rectangle(c, c) - Pos(0.0, b) * Circle(d)
|
||||||
|
ex5 = extrude(sk5, amount=c)
|
||||||
|
# [Ex. 5]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex5.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# Using Point Lists
|
||||||
|
# [Ex. 6]
|
||||||
|
a, b, c = 80, 60, 10
|
||||||
|
|
||||||
|
sk6 = [loc * Circle(c) for loc in Locations((b, 0), (0, b), (-b, 0), (0, -b))]
|
||||||
|
ex6 = extrude(Circle(a) - sk6, amount=c)
|
||||||
|
# [Ex. 6]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex6.part)
|
||||||
|
##########################################
|
||||||
|
# Polygons
|
||||||
|
# [Ex. 7]
|
||||||
|
a, b, c = 60, 80, 5
|
||||||
|
|
||||||
|
polygons = [
|
||||||
|
loc * RegularPolygon(radius=2 * c, side_count=6)
|
||||||
|
for loc in Locations((0, 3 * c), (0, -3 * c))
|
||||||
|
]
|
||||||
|
sk7 = Rot(0, 0, c) * Rectangle(a, b) - polygons
|
||||||
|
ex7 = extrude(sk7, amount=c)
|
||||||
|
# [Ex. 7]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex7.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 8. Polylines
|
||||||
|
# [Ex. 8]
|
||||||
|
(L, H, W, t) = (100.0, 20.0, 20.0, 1.0)
|
||||||
|
pts = [
|
||||||
|
(0, H / 2.0),
|
||||||
|
(W / 2.0, H / 2.0),
|
||||||
|
(W / 2.0, (H / 2.0 - t)),
|
||||||
|
(t / 2.0, (H / 2.0 - t)),
|
||||||
|
(t / 2.0, (t - H / 2.0)),
|
||||||
|
(W / 2.0, (t - H / 2.0)),
|
||||||
|
(W / 2.0, H / -2.0),
|
||||||
|
(0, H / -2.0),
|
||||||
|
]
|
||||||
|
|
||||||
|
ln = Polyline(*pts)
|
||||||
|
ln += mirror(ln, about=Plane.YZ)
|
||||||
|
|
||||||
|
sk8 = make_face(Plane.YZ * ln)
|
||||||
|
ex8 = extrude(sk8, amount=-L).clean()
|
||||||
|
# [Ex. 8]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex8.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 9. Selectors, fillets, and chamfers
|
||||||
|
# [Ex. 9]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex9 = Part() + Box(length, width, thickness)
|
||||||
|
ex9 = chamfer(*ex9.edges().group_by(Axis.Z)[-1], length=4, target=ex9)
|
||||||
|
ex9 = fillet(*ex9.edges().filter_by(Axis.Z), radius=5, target=ex9)
|
||||||
|
# [Ex. 9]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex9.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 10. Select last edges and Hole
|
||||||
|
# [Ex. 10]
|
||||||
|
ex10 = Part() + Box(length, width, thickness)
|
||||||
|
ex10 = chamfer(*ex10.edges().group_by(Axis.Z)[-1], length=4, target=ex10)
|
||||||
|
ex10 = fillet(*ex10.edges().filter_by(Axis.Z), radius=5, target=ex10)
|
||||||
|
|
||||||
|
snapshot = ex10.edges()
|
||||||
|
ex10 -= Hole(radius=width / 4, depth=thickness)
|
||||||
|
last_edges = ex10.edges() - snapshot
|
||||||
|
ex10 = fillet(last_edges.sort_by().last, radius=2, target=ex10)
|
||||||
|
# [Ex. 10]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex10.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 11. Use a face as workplane for BuildSketch and introduce GridLocations
|
||||||
|
# [Ex. 11]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex11 = Part() + Box(length, width, thickness)
|
||||||
|
ex11 = chamfer(*ex11.edges().group_by()[-1], length=4, target=ex11)
|
||||||
|
ex11 = fillet(*ex11.edges().filter_by(Axis.Z), radius=5, target=ex11)
|
||||||
|
last = ex11.edges()
|
||||||
|
ex11 -= Hole(radius=width / 4, depth=thickness)
|
||||||
|
ex11 = fillet((ex11.edges() - last).sort_by().last, radius=2, target=ex11)
|
||||||
|
|
||||||
|
plane = Plane(ex11.faces().sort_by().last)
|
||||||
|
polygons = Sketch() + [
|
||||||
|
plane * loc * RegularPolygon(radius=5, side_count=5)
|
||||||
|
for loc in GridLocations(length / 2, width / 2, 2, 2)
|
||||||
|
]
|
||||||
|
ex11 -= extrude(polygons, amount=-thickness)
|
||||||
|
# [Ex. 11]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex11)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 12. Defining an Edge with a Spline
|
||||||
|
# [Ex. 12]
|
||||||
|
sPnts = [
|
||||||
|
(55, 30),
|
||||||
|
(50, 35),
|
||||||
|
(40, 30),
|
||||||
|
(30, 20),
|
||||||
|
(20, 25),
|
||||||
|
(10, 20),
|
||||||
|
(0, 20),
|
||||||
|
]
|
||||||
|
|
||||||
|
l1 = Spline(*sPnts)
|
||||||
|
l2 = Line(l1 @ 0, (60, 0))
|
||||||
|
l3 = Line(l2 @ 1, (0, 0))
|
||||||
|
l4 = Line(l3 @ 1, l1 @ 1)
|
||||||
|
|
||||||
|
sk12 = make_face(l1, l2, l3, l4)
|
||||||
|
ex12 = extrude(sk12, amount=10)
|
||||||
|
# [Ex. 12]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex12.part)
|
||||||
|
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 13. CounterBoreHoles, CounterSinkHoles and PolarLocations
|
||||||
|
# [Ex. 13]
|
||||||
|
a, b = 40, 4
|
||||||
|
|
||||||
|
ex13 = Cylinder(radius=50, height=10)
|
||||||
|
plane = Plane(ex13.faces().sort_by().last)
|
||||||
|
|
||||||
|
ex13 -= [
|
||||||
|
plane * loc * CounterSinkHole(radius=b, counter_sink_radius=2 * b, depth=10)
|
||||||
|
for loc in PolarLocations(radius=a, count=4)
|
||||||
|
]
|
||||||
|
ex13 -= [
|
||||||
|
plane
|
||||||
|
* loc
|
||||||
|
* CounterBoreHole(
|
||||||
|
radius=b, counter_bore_radius=2 * b, depth=10, counter_bore_depth=b
|
||||||
|
)
|
||||||
|
for loc in PolarLocations(radius=a, count=4, start_angle=45, angular_range=360)
|
||||||
|
]
|
||||||
|
# [Ex. 13]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex13.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 14. Position on a line with '@', '%' and introduce Sweep
|
||||||
|
# [Ex. 14]
|
||||||
|
a, b = 40, 20
|
||||||
|
|
||||||
|
l1 = JernArc(start=(0, 0), tangent=(0, 1), radius=a, arc_size=180)
|
||||||
|
l2 = JernArc(start=l1 @ 1, tangent=l1 % 1, radius=a, arc_size=-90)
|
||||||
|
l3 = Line(l2 @ 1, l2 @ 1 + Vector(-a, a))
|
||||||
|
ex14_ln = l1 + l2 + l3
|
||||||
|
|
||||||
|
sk14 = Plane.XZ * Rectangle(b, b)
|
||||||
|
ex14 = sweep(sk14, path=ex14_ln.wires()[0])
|
||||||
|
# [Ex. 14]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex14.part)
|
||||||
|
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 15. Mirroring Symmetric Geometry
|
||||||
|
# [Ex. 15]
|
||||||
|
a, b, c = 80, 40, 20
|
||||||
|
|
||||||
|
l1 = Line((0, 0), (a, 0))
|
||||||
|
l2 = Line(l1 @ 1, l1 @ 1 + Vector(0, b))
|
||||||
|
l3 = Line(l2 @ 1, l2 @ 1 + Vector(-c, 0))
|
||||||
|
l4 = Line(l3 @ 1, l3 @ 1 + Vector(0, -c))
|
||||||
|
l5 = Line(l4 @ 1, Vector(0, (l4 @ 1).Y))
|
||||||
|
ln = Curve() + [l1, l2, l3, l4, l5]
|
||||||
|
ln += mirror(ln, about=Plane.YZ)
|
||||||
|
|
||||||
|
sk15 = make_face(ln)
|
||||||
|
ex15 = extrude(sk15, amount=c)
|
||||||
|
# [Ex. 15]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex15.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 16. Mirroring 3D Objects
|
||||||
|
# same concept as CQ docs, but different object
|
||||||
|
# [Ex. 16]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
sk16 = Rectangle(length, width)
|
||||||
|
sk16 = fillet(*sk16.vertices(), radius=length / 10, target=sk16)
|
||||||
|
circles = [loc * Circle(length / 12) for loc in GridLocations(length / 4, 0, 3, 1)]
|
||||||
|
sk16 = sk16 - circles - Rectangle(length, width, align=(Align.MIN, Align.MIN))
|
||||||
|
ex16_single = extrude(Plane.XZ * sk16, amount=length)
|
||||||
|
|
||||||
|
planes = [
|
||||||
|
Plane.XY.offset(width),
|
||||||
|
Plane.YX.offset(width),
|
||||||
|
Plane.YZ.offset(width),
|
||||||
|
Plane.YZ.offset(-width),
|
||||||
|
]
|
||||||
|
objs = [mirror(ex16_single, about=plane) for plane in planes]
|
||||||
|
ex16 = ex16_single + objs
|
||||||
|
|
||||||
|
# [Ex. 16]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex16.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 17. Mirroring From Faces
|
||||||
|
# [Ex. 17]
|
||||||
|
a, b = 30, 20
|
||||||
|
|
||||||
|
sk17 = RegularPolygon(radius=a, side_count=5)
|
||||||
|
ex17 = extrude(sk17, amount=b)
|
||||||
|
ex17 += mirror(ex17, about=Plane(ex17.faces().sort_by(Axis.Y).first))
|
||||||
|
# [Ex. 17]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex17.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 18. Creating Workplanes on Faces
|
||||||
|
# based on Ex. 9
|
||||||
|
# [Ex. 18]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
a, b = 4, 5
|
||||||
|
|
||||||
|
ex18 = Part() + Box(length, width, thickness)
|
||||||
|
ex18 = chamfer(*ex18.edges().group_by()[-1], length=a, target=ex18)
|
||||||
|
ex18 = fillet(*ex18.edges().filter_by(Axis.Z), radius=b, target=ex18)
|
||||||
|
|
||||||
|
sk18 = Plane(ex18.faces().sort_by().first) * Rectangle(2 * b, 2 * b)
|
||||||
|
ex18 -= extrude(sk18, amount=-thickness)
|
||||||
|
# [Ex. 18]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex18.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 19. Locating a Workplane on a vertex
|
||||||
|
# [Ex. 19]
|
||||||
|
length, thickness = 80.0, 10.0
|
||||||
|
|
||||||
|
ex19_sk = RegularPolygon(radius=length / 2, side_count=7)
|
||||||
|
ex19 = extrude(ex19_sk, amount=thickness)
|
||||||
|
|
||||||
|
topf = ex19.faces().sort_by().last
|
||||||
|
|
||||||
|
vtx = topf.vertices().group_by(Axis.X)[-1][0]
|
||||||
|
|
||||||
|
vtx2Axis = Axis((0, 0, 0), (-1, -0.5, 0))
|
||||||
|
vtx2 = topf.vertices().sort_by(vtx2Axis)[-1]
|
||||||
|
|
||||||
|
ex19_sk2 = Circle(radius=length / 8)
|
||||||
|
ex19_sk2 = Pos(vtx.X, vtx.Y) * ex19_sk2 + Pos(vtx2.X, vtx2.Y) * ex19_sk2
|
||||||
|
|
||||||
|
ex19 -= extrude(ex19_sk2, amount=thickness)
|
||||||
|
# [Ex. 19]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex19.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 20. Offset Sketch Workplane
|
||||||
|
# [Ex. 20]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex20 = Box(length, width, thickness)
|
||||||
|
plane = Plane(ex20.faces().sort_by(Axis.X).first).offset(2 * thickness)
|
||||||
|
|
||||||
|
sk20 = plane * Circle(width / 3)
|
||||||
|
ex20 += extrude(sk20, amount=width)
|
||||||
|
# [Ex. 20]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex20.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 21. Copying Workplanes
|
||||||
|
# [Ex. 21]
|
||||||
|
width, length = 10.0, 60.0
|
||||||
|
|
||||||
|
ex21 = extrude(Circle(width / 2), amount=length)
|
||||||
|
plane = Plane(origin=ex21.center(), z_dir=(-1, 0, 0))
|
||||||
|
ex21 += plane * extrude(Circle(width / 2), amount=length)
|
||||||
|
# [Ex. 21]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex21.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 22. Rotated Workplanes
|
||||||
|
# [Ex. 22]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex22 = Box(length, width, thickness)
|
||||||
|
plane = Plane((ex22.faces().group_by(Axis.Z)[0])[0]) * Rot(0, 50, 0)
|
||||||
|
|
||||||
|
holes = Sketch() + [
|
||||||
|
plane * loc * Circle(thickness / 4)
|
||||||
|
for loc in GridLocations(length / 4, width / 4, 2, 2)
|
||||||
|
]
|
||||||
|
ex22 -= extrude(holes, amount=-100, both=True)
|
||||||
|
# [Ex. 22]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex22.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 23. Revolve
|
||||||
|
# [Ex. 23]
|
||||||
|
pts = [
|
||||||
|
(-25, 35),
|
||||||
|
(-25, 0),
|
||||||
|
(-20, 0),
|
||||||
|
(-20, 5),
|
||||||
|
(-15, 10),
|
||||||
|
(-15, 35),
|
||||||
|
]
|
||||||
|
|
||||||
|
l1 = Polyline(*pts)
|
||||||
|
l2 = Line(l1 @ 1, l1 @ 0)
|
||||||
|
sk23 = make_face(l1, l2)
|
||||||
|
|
||||||
|
sk23 += Pos(0, 35) * Circle(25)
|
||||||
|
sk23 = Plane.XZ * split(sk23, bisect_by=Plane.ZY)
|
||||||
|
|
||||||
|
ex23 = revolve(sk23, axis=Axis.Z)
|
||||||
|
# [Ex. 23]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex23.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 24. Lofts
|
||||||
|
# [Ex. 24]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex24 = Box(length, length, thickness)
|
||||||
|
plane = Plane(ex24.faces().sort_by().last)
|
||||||
|
|
||||||
|
faces = Sketch() + [
|
||||||
|
plane * Circle(length / 3),
|
||||||
|
plane.offset(length / 2) * Rectangle(length / 6, width / 6),
|
||||||
|
]
|
||||||
|
|
||||||
|
ex24 += loft(faces)
|
||||||
|
# [Ex. 24]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex24.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 25. Offset Sketch
|
||||||
|
# [Ex. 25]
|
||||||
|
rad, offs = 50, 10
|
||||||
|
|
||||||
|
sk25_1 = RegularPolygon(radius=rad, side_count=5)
|
||||||
|
sk25_2 = Plane.XY.offset(15) * RegularPolygon(radius=rad, side_count=5)
|
||||||
|
sk25_2 = offset(sk25_2, amount=offs)
|
||||||
|
sk25_3 = Plane.XY.offset(30) * RegularPolygon(radius=rad, side_count=5)
|
||||||
|
sk25_3 = offset(sk25_3, amount=offs, kind=Kind.INTERSECTION)
|
||||||
|
|
||||||
|
sk25 = Sketch() + [sk25_1, sk25_2, sk25_3]
|
||||||
|
ex25 = extrude(sk25, amount=1)
|
||||||
|
# [Ex. 25]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex25.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 26. Offset Part To Create Thin features
|
||||||
|
# [Ex. 26]
|
||||||
|
length, width, thickness, wall = 80.0, 60.0, 10.0, 2.0
|
||||||
|
|
||||||
|
ex26 = Box(length, width, thickness)
|
||||||
|
topf = ex26.faces().sort_by().last
|
||||||
|
ex26 = offset(ex26, amount=-wall, openings=topf)
|
||||||
|
# [Ex. 26]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex26.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 27. Splitting an Object
|
||||||
|
# [Ex. 27]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex27 = Box(length, width, thickness)
|
||||||
|
sk27 = Plane(ex27.faces().sort_by().first) * Circle(width / 4)
|
||||||
|
ex27 -= extrude(sk27, amount=-thickness)
|
||||||
|
ex27 = split(
|
||||||
|
ex27, bisect_by=Plane(ex27.faces().sort_by(Axis.Y).last).offset(-width / 2)
|
||||||
|
)
|
||||||
|
# [Ex. 27]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex27.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 28. Locating features based on Faces
|
||||||
|
# [Ex. 28]
|
||||||
|
width, thickness = 80.0, 10.0
|
||||||
|
|
||||||
|
sk28 = RegularPolygon(radius=width / 4, side_count=3)
|
||||||
|
tmp28 = extrude(sk28, amount=thickness)
|
||||||
|
ex28 = Sphere(radius=width / 2)
|
||||||
|
for p in [Plane(face) for face in tmp28.faces().group_by(Axis.Z)[1]]:
|
||||||
|
ex28 -= p * Hole(thickness / 2, depth=width)
|
||||||
|
# [Ex. 28]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex28.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 29. The Classic OCC Bottle
|
||||||
|
# [Ex. 29]
|
||||||
|
L, w, t, b, h, n = 60.0, 18.0, 9.0, 0.9, 90.0, 8.0
|
||||||
|
|
||||||
|
l1 = Line((0, 0), (0, w / 2))
|
||||||
|
l2 = ThreePointArc(l1 @ 1, (L / 2.0, w / 2.0 + t), (L, w / 2.0))
|
||||||
|
l3 = Line(l2 @ 1, Vector((l2 @ 1).X, 0, 0))
|
||||||
|
ln29 = l1 + l2 + l3
|
||||||
|
ln29 += mirror(ln29)
|
||||||
|
sk29 = make_face(ln29)
|
||||||
|
ex29 = extrude(sk29, amount=-(h + b))
|
||||||
|
# ex29 = fillet(*ex29.edges(), radius=w / 8, target=ex29)
|
||||||
|
|
||||||
|
neck = Plane(ex29.faces().sort_by().last) * Circle(t)
|
||||||
|
ex29 += extrude(neck, amount=n)
|
||||||
|
necktopf = ex29.faces().sort_by().last
|
||||||
|
ex29 = offset(ex29, amount=-b, openings=necktopf)
|
||||||
|
# [Ex. 29]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex29.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 30. Bezier Curve
|
||||||
|
# [Ex. 30]
|
||||||
|
pts = [
|
||||||
|
(0, 0),
|
||||||
|
(20, 20),
|
||||||
|
(40, 0),
|
||||||
|
(0, -40),
|
||||||
|
(-60, 0),
|
||||||
|
(0, 100),
|
||||||
|
(100, 0),
|
||||||
|
]
|
||||||
|
|
||||||
|
wts = [
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
3.0,
|
||||||
|
4.0,
|
||||||
|
2.0,
|
||||||
|
1.0,
|
||||||
|
]
|
||||||
|
|
||||||
|
ex30_ln = Polyline(*pts) + Bezier(*pts, weights=wts)
|
||||||
|
ex30_sk = make_face(ex30_ln)
|
||||||
|
ex30 = extrude(ex30_sk, amount=-10)
|
||||||
|
# [Ex. 30]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex30.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 31. Nesting Locations
|
||||||
|
# [Ex. 31]
|
||||||
|
a, b, c = 80.0, 5.0, 3.0
|
||||||
|
|
||||||
|
ex31 = Sketch()
|
||||||
|
|
||||||
|
for ploc in PolarLocations(a / 2, 6):
|
||||||
|
ex31 += ploc * RegularPolygon(b, 4)
|
||||||
|
for gloc in GridLocations(3 * b, 3 * b, 2, 2):
|
||||||
|
ex31 += ploc * gloc * RegularPolygon(b, 3)
|
||||||
|
|
||||||
|
ex31 += Rot(z=30) * RegularPolygon(3 * b, 6)
|
||||||
|
ex31 = extrude(ex31, 3)
|
||||||
|
# [Ex. 31]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex31.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 32. Python for-loop
|
||||||
|
# [Ex. 32]
|
||||||
|
a, b, c = 80.0, 10.0, 1.0
|
||||||
|
|
||||||
|
ex32_sk = RegularPolygon(2 * b, 6, rotation=30)
|
||||||
|
ex32_sk += [loc * RegularPolygon(b, 4) for loc in PolarLocations(a / 2, 6)]
|
||||||
|
ex32 = Part() + [
|
||||||
|
extrude(obj, amount=c + 3 * idx) for idx, obj in enumerate(ex32_sk.faces())
|
||||||
|
]
|
||||||
|
# [Ex. 32]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex32.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 33. Python function and for-loop
|
||||||
|
# [Ex. 33]
|
||||||
|
a, b, c = 80.0, 5.0, 1.0
|
||||||
|
|
||||||
|
|
||||||
|
def square(rad, loc):
|
||||||
|
return loc * RegularPolygon(rad, 4)
|
||||||
|
|
||||||
|
|
||||||
|
ex33 = Part() + [
|
||||||
|
extrude(square(b + 2 * i, loc), amount=c + 2 * i)
|
||||||
|
for i, loc in enumerate(PolarLocations(a / 2, 6))
|
||||||
|
]
|
||||||
|
|
||||||
|
# [Ex. 33]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex33.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 34. Embossed and Debossed Text
|
||||||
|
# [Ex. 34]
|
||||||
|
length, width, thickness, fontsz, fontht = 80.0, 60.0, 10.0, 25.0, 4.0
|
||||||
|
|
||||||
|
ex34 = Box(length, width, thickness)
|
||||||
|
plane = Plane(ex34.faces().sort_by().last)
|
||||||
|
ex34_sk = plane * Text("Hello", font_size=fontsz, align=(Align.CENTER, Align.MIN))
|
||||||
|
ex34 += extrude(ex34_sk, amount=fontht)
|
||||||
|
ex34_sk2 = plane * Text("World", font_size=fontsz, align=(Align.CENTER, Align.MAX))
|
||||||
|
ex34 -= extrude(ex34_sk2, amount=-fontht)
|
||||||
|
# [Ex. 34]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex34.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 35. Slots
|
||||||
|
# [Ex. 35]
|
||||||
|
length, width, thickness = 80.0, 60.0, 10.0
|
||||||
|
|
||||||
|
ex35 = Box(length, length, thickness)
|
||||||
|
plane = Plane(ex35.faces().sort_by().last)
|
||||||
|
ex35_sk = SlotCenterToCenter(width / 2, 10)
|
||||||
|
ex35_ln = RadiusArc((-width / 2, 0), (0, width / 2), radius=width / 2)
|
||||||
|
ex35_sk += SlotArc(arc=ex35_ln.edges()[0], height=thickness)
|
||||||
|
ex35_ln2 = RadiusArc((0, -width / 2), (width / 2, 0), radius=-width / 2)
|
||||||
|
ex35_sk += SlotArc(arc=ex35_ln2.edges()[0], height=thickness)
|
||||||
|
ex35 -= extrude(plane * ex35_sk, amount=-thickness)
|
||||||
|
# [Ex. 35]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex35.part)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 36. Extrude-Until
|
||||||
|
# [Ex. 36]
|
||||||
|
rad, rev = 6, 50
|
||||||
|
|
||||||
|
ex36_sk = Pos(0, rev) * Circle(rad)
|
||||||
|
ex36 = revolve(ex36_sk, axis=Axis.X, revolution_arc=180)
|
||||||
|
ex36_sk2 = Rectangle(rad, rev)
|
||||||
|
ex36 += extrude(ex36_sk2, until=Until.NEXT, target=ex36)
|
||||||
|
|
||||||
|
# [Ex. 36]
|
||||||
|
|
||||||
|
svgout(ex_counter)
|
||||||
|
|
||||||
|
ex_counter += 1
|
||||||
|
|
||||||
|
# show_object(ex36.part)
|
||||||
|
|
@ -94,6 +94,7 @@ Table Of Contents
|
||||||
introduction.rst
|
introduction.rst
|
||||||
installation.rst
|
installation.rst
|
||||||
introductory_examples.rst
|
introductory_examples.rst
|
||||||
|
introductory_examples_algebra.rst
|
||||||
tutorials.rst
|
tutorials.rst
|
||||||
builders.rst
|
builders.rst
|
||||||
advanced.rst
|
advanced.rst
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#####################
|
####################################
|
||||||
Introductory Examples
|
Introductory Examples (context mode)
|
||||||
#####################
|
####################################
|
||||||
|
|
||||||
The examples on this page can help you learn how to build objects with Build123d, and are intended as a general overview of Build123d.
|
The examples on this page can help you learn how to build objects with Build123d, and are intended as a general overview of Build123d.
|
||||||
|
|
||||||
|
|
@ -34,8 +34,8 @@ Just about the simplest possible example, a rectangular :class:`~build_part.Box`
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
A rectangular box, but with a hole added. In this case we are using
|
A rectangular box, but with a hole added. In this case we are using
|
||||||
:class:`~build_enums.Mode` ``.SUBTRACT`` to cut the :class:`~build_part.Cylinder`
|
:class:`~build_enums.Mode` ``.SUBTRACT`` to cut the :class:`~objects_part.Cylinder`
|
||||||
from the :class:`~build_part.Box`.
|
from the :class:`~objects_part.Box`.
|
||||||
|
|
||||||
.. image:: assets/general_ex2.svg
|
.. image:: assets/general_ex2.svg
|
||||||
:align: center
|
:align: center
|
||||||
|
|
@ -49,7 +49,7 @@ from the :class:`~build_part.Box`.
|
||||||
|
|
||||||
Build a prismatic solid using extrusion. This time we can first create a 2D
|
Build a prismatic solid using extrusion. This time we can first create a 2D
|
||||||
:class:`~build_sketch.BuildSketch` with a subtracted Rectangle and then use
|
:class:`~build_sketch.BuildSketch` with a subtracted Rectangle and then use
|
||||||
:class:`~build_part.BuildPart`'s :class:`~build_part.Extrude` feature.
|
:class:`~build_part.BuildPart`'s :class:`~operations_part.extrude` feature.
|
||||||
|
|
||||||
.. image:: assets/general_ex3.svg
|
.. image:: assets/general_ex3.svg
|
||||||
:align: center
|
:align: center
|
||||||
|
|
@ -65,7 +65,7 @@ Sometimes you need to build complex profiles using lines and arcs. This example
|
||||||
builds a prismatic solid from 2D operations. It is not necessary to create
|
builds a prismatic solid from 2D operations. It is not necessary to create
|
||||||
variables for the line segments, but it will be useful in a later example.
|
variables for the line segments, but it will be useful in a later example.
|
||||||
:class:`~build_sketch.BuildSketch` operates on closed Faces, and the operation
|
:class:`~build_sketch.BuildSketch` operates on closed Faces, and the operation
|
||||||
:class:`~build_sketch.MakeFace` is used to convert the pending line segments
|
:class:`~operations_sketch.make_face` is used to convert the pending line segments
|
||||||
from :class:`~build_line.BuildLine` into a closed Face. Note that to build a
|
from :class:`~build_line.BuildLine` into a closed Face. Note that to build a
|
||||||
closed face it requires line segments that form a closed shape.
|
closed face it requires line segments that form a closed shape.
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ multiple objects at once.
|
||||||
7. Polygons
|
7. Polygons
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
You can create :class:`~build_sketch.RegularPolygon` for each stack point if
|
You can create :class:`~objects_sketch.RegularPolygon` for each stack point if
|
||||||
you would like.
|
you would like.
|
||||||
|
|
||||||
.. image:: assets/general_ex7.svg
|
.. image:: assets/general_ex7.svg
|
||||||
|
|
@ -119,9 +119,9 @@ you would like.
|
||||||
8. Polylines
|
8. Polylines
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
:class:`~build_line.Polyline` allows creating a shape from a large number
|
:class:`~objects_line.Polyline` allows creating a shape from a large number
|
||||||
of chained points connected by lines. This example uses a polyline to create
|
of chained points connected by lines. This example uses a polyline to create
|
||||||
one half of an i-beam shape, which is :class:`~build_generic.Mirror` ed to
|
one half of an i-beam shape, which is :class:`~operations_generic.mirror` ed to
|
||||||
create the final profile.
|
create the final profile.
|
||||||
|
|
||||||
.. image:: assets/general_ex8.svg
|
.. image:: assets/general_ex8.svg
|
||||||
|
|
@ -134,8 +134,8 @@ create the final profile.
|
||||||
9. Selectors, Fillets, and Chamfers
|
9. Selectors, Fillets, and Chamfers
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
This example introduces multiple useful and important concepts. Firstly :class:`~build_generic.Chamfer`
|
This example introduces multiple useful and important concepts. Firstly :class:`~operations_generic.chamfer`
|
||||||
and :class:`~build_generic.Fillet` can be used to "bevel" and "round" edges respectively. Secondly,
|
and :class:`~operations_generic.fillet` can be used to "bevel" and "round" edges respectively. Secondly,
|
||||||
these two methods require an edge or a list of edges to operate on. To select all
|
these two methods require an edge or a list of edges to operate on. To select all
|
||||||
edges, you could simply pass-in ``*ex9.edges()``. Note that the star (\*) unpacks
|
edges, you could simply pass-in ``*ex9.edges()``. Note that the star (\*) unpacks
|
||||||
the list.
|
the list.
|
||||||
|
|
@ -155,8 +155,9 @@ convention, will be the highest z-dimension group.
|
||||||
10. Select Last and Hole
|
10. Select Last and Hole
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
Using :class:`~build_enums.Select` ``.LAST`` you can select the most recently modified edges. It is used to perform a :class:`~build_generic.Fillet` in
|
Using :class:`~build_enums.Select` ``.LAST`` you can select the most recently modified edges.
|
||||||
this example. This example also makes use of :class:`~build_part.Hole` which automatically cuts through the entire part.
|
It is used to perform a :class:`~operations_generic.fillet` in this example. This example also
|
||||||
|
makes use of :class:`~objects_part.Hole` which automatically cuts through the entire part.
|
||||||
|
|
||||||
.. image:: assets/general_ex10.svg
|
.. image:: assets/general_ex10.svg
|
||||||
:align: center
|
:align: center
|
||||||
|
|
@ -174,7 +175,7 @@ to be Planar or unpredictable behavior can result. Additionally :class:`~build_c
|
||||||
can be used to create a grid of points that are simultaneously used to place 4
|
can be used to create a grid of points that are simultaneously used to place 4
|
||||||
pentagons.
|
pentagons.
|
||||||
|
|
||||||
Lastly, :class:`~build_part.Extrude` can be used with a negative amount and ``Mode.SUBTRACT`` to
|
Lastly, :class:`~operations_part.extrude` can be used with a negative amount and ``Mode.SUBTRACT`` to
|
||||||
cut these from the parent. Note that the direction implied by positive or negative
|
cut these from the parent. Note that the direction implied by positive or negative
|
||||||
inputs to amount is relative to the normal direction of the face or plane. As a
|
inputs to amount is relative to the normal direction of the face or plane. As a
|
||||||
result of this, unexpected behavior can occur if the extrude direction and mode
|
result of this, unexpected behavior can occur if the extrude direction and mode
|
||||||
|
|
@ -232,9 +233,9 @@ consuming, and more difficult to maintain.
|
||||||
It is also possible to use :class:`~geometry.Vector` addition (and other vector math operations)
|
It is also possible to use :class:`~geometry.Vector` addition (and other vector math operations)
|
||||||
as seen in the ``l3`` variable.
|
as seen in the ``l3`` variable.
|
||||||
|
|
||||||
The :class:`~build_part.Sweep` method takes any pending faces and sweeps them through the provided
|
The :class:`~operations_part.sweep` method takes any pending faces and sweeps them through the provided
|
||||||
path (in this case the path is taken from the pending edges from ``ex14_ln``).
|
path (in this case the path is taken from the pending edges from ``ex14_ln``).
|
||||||
:class:`~build_part.Revolve` requires a single connected wire. The pending faces must lie on the
|
:class:`~operations_part.revolve` requires a single connected wire. The pending faces must lie on the
|
||||||
path.
|
path.
|
||||||
|
|
||||||
.. image:: assets/general_ex14.svg
|
.. image:: assets/general_ex14.svg
|
||||||
|
|
@ -360,8 +361,8 @@ extruded in the "both" (positive and negative) normal direction.
|
||||||
23. Revolve
|
23. Revolve
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
Here we build a sketch with a :class:`~build_line.Polyline`,
|
Here we build a sketch with a :class:`~objects_curve.Polyline`,
|
||||||
:class:`~build_line.Line`, and a :class:`~build_sketch.Circle`. It is
|
:class:`~objects_curve.Line`, and a :class:`~objects_sketch.Circle`. It is
|
||||||
absolutely critical that the sketch is only on one side of the axis of rotation
|
absolutely critical that the sketch is only on one side of the axis of rotation
|
||||||
before Revolve is called.
|
before Revolve is called.
|
||||||
|
|
||||||
|
|
@ -382,7 +383,7 @@ can be accomplished e.g. like this: ``show_object(ex23_sk.sketch)``.
|
||||||
|
|
||||||
Loft is a very powerful tool that can be used to join dissimilar shapes. In this case we make a
|
Loft is a very powerful tool that can be used to join dissimilar shapes. In this case we make a
|
||||||
conical-like shape from a circle and a rectangle that is offset vertically. In this case
|
conical-like shape from a circle and a rectangle that is offset vertically. In this case
|
||||||
:class:`~build_part.Loft` automatically takes the pending faces that were added by the two BuildSketches.
|
:class:`~operations_part.loft` automatically takes the pending faces that were added by the two BuildSketches.
|
||||||
Loft can behave unexpectedly when the input faces are not parallel to each other.
|
Loft can behave unexpectedly when the input faces are not parallel to each other.
|
||||||
|
|
||||||
.. image:: assets/general_ex24.svg
|
.. image:: assets/general_ex24.svg
|
||||||
|
|
@ -395,7 +396,7 @@ Loft can behave unexpectedly when the input faces are not parallel to each other
|
||||||
25. Offset Sketch
|
25. Offset Sketch
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
BuildSketch faces can be transformed with a 2D :class:`~build_generic.Offset`. They can be offset inwards or outwards,
|
BuildSketch faces can be transformed with a 2D :class:`~operations_generic.offset`. They can be offset inwards or outwards,
|
||||||
and with different techniques for extending the corners (see :class:`~build_enums.Kind` in the Offset docs).
|
and with different techniques for extending the corners (see :class:`~build_enums.Kind` in the Offset docs).
|
||||||
|
|
||||||
.. image:: assets/general_ex25.svg
|
.. image:: assets/general_ex25.svg
|
||||||
|
|
@ -409,9 +410,9 @@ and with different techniques for extending the corners (see :class:`~build_enum
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
BuildPart parts can also be transformed using an offset, but in this case with
|
BuildPart parts can also be transformed using an offset, but in this case with
|
||||||
a 3D :class:`~build_generic.Offset`. Also commonly known as a shell, this allows creating thin walls
|
a 3D :class:`~operations_generic.offset`. Also commonly known as a shell, this allows creating thin walls
|
||||||
using very few operations. This can also be offset inwards or outwards. Faces
|
using very few operations. This can also be offset inwards or outwards. Faces
|
||||||
can be selected to be "deleted" using the ``openings`` parameter of :class:`~build_generic.Offset`.
|
can be selected to be "deleted" using the ``openings`` parameter of :class:`~operations_generic.offset`.
|
||||||
|
|
||||||
Note that self intersecting edges and/or faces can break both 2D and 3D offsets.
|
Note that self intersecting edges and/or faces can break both 2D and 3D offsets.
|
||||||
|
|
||||||
|
|
@ -466,8 +467,8 @@ the bottle opening.
|
||||||
30. Bezier Curve
|
30. Bezier Curve
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
Here ``pts`` is used as an input to both :class:`~build_line.Polyline` and
|
Here ``pts`` is used as an input to both :class:`~objects_curve.Polyline` and
|
||||||
:class:`~build_line.Bezier` and ``wts`` to Bezier alone. These two together
|
:class:`~objects_curve.Bezier` and ``wts`` to Bezier alone. These two together
|
||||||
create a closed line that is made into a face and extruded.
|
create a closed line that is made into a face and extruded.
|
||||||
|
|
||||||
.. image:: assets/general_ex30.svg
|
.. image:: assets/general_ex30.svg
|
||||||
|
|
@ -496,8 +497,8 @@ rotates any "children" groups by default.
|
||||||
|
|
||||||
In this example, a standard python for-loop is used along with a list of faces extracted from a BuildSketch
|
In this example, a standard python for-loop is used along with a list of faces extracted from a BuildSketch
|
||||||
to progressively modify the extrusion amount. There are 7 faces in the BuildSketch, so this results in 7
|
to progressively modify the extrusion amount. There are 7 faces in the BuildSketch, so this results in 7
|
||||||
separate calls to :class:`~build_part.Extrude`. :class:`~build_enums.Mode` ``.PRIVATE``
|
separate calls to :class:`~operations_part.extrude`. :class:`~build_enums.Mode` ``.PRIVATE``
|
||||||
is used in :class:`~build_sketch.BuildSketch` to avoid adding these faces until the for-loop.
|
is used in :class:`~build_sketch.BuildSketch` to avoid adding these faces until the for-loop.
|
||||||
|
|
||||||
.. image:: assets/general_ex32.svg
|
.. image:: assets/general_ex32.svg
|
||||||
:align: center
|
:align: center
|
||||||
|
|
@ -539,9 +540,9 @@ the 2nd "World" text on the top of the "Hello" text.
|
||||||
35. Slots
|
35. Slots
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
Here we create a :class:`~build_sketch.SlotCenterToCenter` and then use a
|
Here we create a :class:`~objects_sketch.SlotCenterToCenter` and then use a
|
||||||
:class:`~build_line.BuildLine` and :class:`~build_line.RadiusArc` to create an
|
:class:`~build_line.BuildLine` and :class:`~build_line.RadiusArc` to create an
|
||||||
arc for two instances of :class:`~build_sketch.SlotArc`.
|
arc for two instances of :class:`~objects_sketch.SlotArc`.
|
||||||
|
|
||||||
.. image:: assets/general_ex35.svg
|
.. image:: assets/general_ex35.svg
|
||||||
:align: center
|
:align: center
|
||||||
|
|
@ -555,7 +556,7 @@ arc for two instances of :class:`~build_sketch.SlotArc`.
|
||||||
|
|
||||||
Sometimes you will want to extrude until a given face that can be not planar or
|
Sometimes you will want to extrude until a given face that can be not planar or
|
||||||
where you might not know easily the distance you have to extrude to. In such
|
where you might not know easily the distance you have to extrude to. In such
|
||||||
cases you can use :class:`~build_part.Extrude` :class:`~build_enums.Until`
|
cases you can use :class:`~operations_part.extrude` :class:`~build_enums.Until`
|
||||||
with ``Until.NEXT`` or ``Until.LAST``.
|
with ``Until.NEXT`` or ``Until.LAST``.
|
||||||
|
|
||||||
.. image:: assets/general_ex36.svg
|
.. image:: assets/general_ex36.svg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue