mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Merge branch 'algebra' of https://github.com/gumyr/build123d into algebra
This commit is contained in:
commit
972c6c666f
7 changed files with 103 additions and 56 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from build123d import *
|
||||
|
||||
b = Box(3, 3, 3)
|
||||
b2 = Rot(0, 0, 45) * extrude(Rectangle(1, 2), 0.2)
|
||||
b2 = Rot(0, 0, 45) * extrude(Rectangle(1, 2), 0.1)
|
||||
for plane in [Plane(f) for f in b.faces()]:
|
||||
b += plane * b2
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,10 @@ minute_indicator = make_face([l1, l3, l2, l4])
|
|||
minute_indicator = fillet(minute_indicator.vertices(), radius=clock_radius * 0.01)
|
||||
|
||||
clock_face = Circle(clock_radius)
|
||||
clock_face -= [loc * minute_indicator for loc in PolarLocations(0, 60)]
|
||||
|
||||
|
||||
clock_face -= [
|
||||
loc * SlotOverall(clock_radius * 0.05, clock_radius * 0.025)
|
||||
for loc in PolarLocations(clock_radius * 0.875, 12)
|
||||
]
|
||||
clock_face -= PolarLocations(0, 60) * minute_indicator
|
||||
clock_face -= PolarLocations(clock_radius * 0.875, 12) * SlotOverall(
|
||||
clock_radius * 0.05, clock_radius * 0.025
|
||||
)
|
||||
|
||||
clock_face -= [
|
||||
loc
|
||||
|
|
|
|||
|
|
@ -23,14 +23,8 @@ tube_locations = [
|
|||
if l.position.length < bundle_diameter / 2
|
||||
]
|
||||
|
||||
tube_plan = Sketch() + [
|
||||
loc
|
||||
* (
|
||||
Circle(radius=tube_diameter / 2)
|
||||
- Circle(radius=tube_diameter / 2 - tube_wall_thickness)
|
||||
)
|
||||
for loc in tube_locations
|
||||
]
|
||||
ring = Circle(tube_diameter / 2) - Circle(tube_diameter / 2 - tube_wall_thickness)
|
||||
tube_plan = Sketch() + tube_locations * ring
|
||||
|
||||
heat_exchanger = extrude(tube_plan, exchanger_length / 2)
|
||||
|
||||
|
|
@ -38,10 +32,10 @@ plate_plane = Plane(
|
|||
origin=(0, 0, exchanger_length / 2 - tube_extension - plate_thickness),
|
||||
z_dir=(0, 0, 1),
|
||||
)
|
||||
plate = Circle(radius=exchanger_diameter / 2) - [
|
||||
loc * Circle(radius=tube_diameter / 2 - tube_wall_thickness)
|
||||
for loc in tube_locations
|
||||
]
|
||||
plate = Circle(radius=exchanger_diameter / 2) - tube_locations * Circle(
|
||||
radius=tube_diameter / 2 - tube_wall_thickness
|
||||
)
|
||||
|
||||
heat_exchanger += extrude(plate_plane * plate, plate_thickness)
|
||||
edges = (
|
||||
heat_exchanger.edges()
|
||||
|
|
|
|||
|
|
@ -28,31 +28,30 @@ plan -= offset(
|
|||
kind=Kind.INTERSECTION,
|
||||
)
|
||||
# Add a grid of lengthwise and widthwise bars
|
||||
for loc in GridLocations(x_spacing=0, y_spacing=lego_unit_size, x_count=1, y_count=2):
|
||||
plan += loc * Rectangle(width=block_length, height=ridge_width)
|
||||
locs = GridLocations(x_spacing=0, y_spacing=lego_unit_size, x_count=1, y_count=2)
|
||||
plan += locs * Rectangle(width=block_length, height=ridge_width)
|
||||
|
||||
for loc in GridLocations(lego_unit_size, 0, pip_count, 1):
|
||||
plan += loc * Rectangle(width=ridge_width, height=block_width)
|
||||
locs = GridLocations(lego_unit_size, 0, pip_count, 1)
|
||||
plan += locs * Rectangle(width=ridge_width, height=block_width)
|
||||
|
||||
# Substract a rectangle leaving ribs on the block walls
|
||||
plan -= Rectangle(
|
||||
block_length - 2 * (wall_thickness + ridge_depth),
|
||||
block_width - 2 * (wall_thickness + ridge_depth),
|
||||
)
|
||||
|
||||
# Add a row of hollow circles to the center
|
||||
for loc in GridLocations(
|
||||
locs = GridLocations(
|
||||
x_spacing=lego_unit_size, y_spacing=0, x_count=pip_count - 1, y_count=1
|
||||
):
|
||||
plan += loc * Circle(support_outer_diameter / 2)
|
||||
plan -= loc * Circle(support_inner_diameter / 2)
|
||||
)
|
||||
ring = Circle(support_outer_diameter / 2) - Circle(support_inner_diameter / 2)
|
||||
plan += locs * ring
|
||||
|
||||
# Extrude this base sketch to the height of the walls
|
||||
lego = extrude(plan, amount=base_height - wall_thickness)
|
||||
|
||||
# Create a box on the top of the walls
|
||||
for loc in Locations((0, 0, lego.vertices().sort_by().last.Z)):
|
||||
# Create the top of the block
|
||||
lego += loc * Box(
|
||||
# Create a box on the top of the walls and the top of the block
|
||||
lego += Pos(0, 0, lego.vertices().sort_by().last.Z) * Box(
|
||||
length=block_length,
|
||||
width=block_width,
|
||||
height=wall_thickness,
|
||||
|
|
@ -63,10 +62,11 @@ for loc in Locations((0, 0, lego.vertices().sort_by().last.Z)):
|
|||
plane = Plane(lego.faces().sort_by().last)
|
||||
|
||||
# Create a grid of pips
|
||||
for loc in GridLocations(lego_unit_size, lego_unit_size, pip_count, 2):
|
||||
|
||||
locs = GridLocations(lego_unit_size, lego_unit_size, pip_count, 2)
|
||||
lego += (
|
||||
plane
|
||||
* loc
|
||||
* locs
|
||||
* Cylinder(
|
||||
radius=pip_diameter / 2,
|
||||
height=pip_height,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from build123d import *
|
||||
|
||||
obj = Box(5, 5, 1)
|
||||
for plane in [Plane(f) for f in obj.faces().filter_by(Axis.Z)]:
|
||||
obj -= plane * Sphere(1.8)
|
||||
planes = [Plane(f) for f in obj.faces().filter_by(Axis.Z)]
|
||||
obj -= planes * Sphere(1.8)
|
||||
|
||||
if "show_object" in locals():
|
||||
show_object(obj)
|
||||
|
|
|
|||
|
|
@ -14,13 +14,11 @@ plane = Plane(pillow_block.faces().sort_by().last)
|
|||
pillow_block -= plane * CounterBoreHole(
|
||||
bearing_axle_radius, bearing_radius, bearing_thickness, height
|
||||
)
|
||||
for loc in GridLocations(width - 2 * padding, height - 2 * padding, 2, 2):
|
||||
locs = GridLocations(width - 2 * padding, height - 2 * padding, 2, 2)
|
||||
pillow_block -= (
|
||||
plane
|
||||
* loc
|
||||
* CounterBoreHole(
|
||||
screw_shaft_radius, screw_head_radius, screw_head_height, height
|
||||
)
|
||||
* locs
|
||||
* CounterBoreHole(screw_shaft_radius, screw_head_radius, screw_head_height, height)
|
||||
)
|
||||
|
||||
# Render the part
|
||||
|
|
|
|||
58
examples/tea_cup_algebra.py
Normal file
58
examples/tea_cup_algebra.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
from build123d import *
|
||||
|
||||
wall_thickness = 3 * MM
|
||||
fillet_radius = wall_thickness * 0.49
|
||||
|
||||
# Create the bowl of the cup as a revolved cross section
|
||||
|
||||
# Start & end points with control tangents
|
||||
s = Spline(
|
||||
(30 * MM, 10 * MM),
|
||||
(69 * MM, 105 * MM),
|
||||
tangents=((1, 0.5), (0.7, 1)),
|
||||
tangent_scalars=(1.75, 1),
|
||||
)
|
||||
# Lines to finish creating ½ the bowl shape
|
||||
s += Polyline(s @ 0, s @ 0 + (10 * MM, -10 * MM), (0, 0), (0, (s @ 1).Y), s @ 1)
|
||||
bowl_section = Plane.XZ * make_face(s) # Create a filled 2D shape
|
||||
tea_cup = revolve(bowl_section, axis=Axis.Z)
|
||||
|
||||
# Hollow out the bowl with openings on the top and bottom
|
||||
tea_cup = offset(
|
||||
tea_cup, amount=-wall_thickness, openings=tea_cup.faces().filter_by(GeomType.PLANE)
|
||||
)
|
||||
|
||||
# Add a bottom to the bowl
|
||||
tea_cup += Pos(0, 0, (s @ 0).Y) * Cylinder(radius=(s @ 0).X, height=wall_thickness)
|
||||
|
||||
# Smooth out all the edges
|
||||
tea_cup = fillet(*tea_cup.edges(), radius=fillet_radius)
|
||||
|
||||
# Determine where the handle contacts the bowl
|
||||
handle_intersections = [
|
||||
tea_cup.find_intersection(
|
||||
Axis(origin=(0, 0, vertical_offset), direction=(1, 0, 0))
|
||||
)[-1][0]
|
||||
for vertical_offset in [35 * MM, 80 * MM]
|
||||
]
|
||||
|
||||
# Create a path for handle creation
|
||||
path_spline = Spline(
|
||||
handle_intersections[0] - (wall_thickness / 2, 0, 0),
|
||||
handle_intersections[0] + (35 * MM, 0, 30 * MM),
|
||||
handle_intersections[0] + (40 * MM, 0, 60 * MM),
|
||||
handle_intersections[1] - (wall_thickness / 2, 0, 0),
|
||||
tangents=((1, 0, 1.25), (-0.2, 0, -1)),
|
||||
)
|
||||
|
||||
# Align the cross section to the beginning of the path
|
||||
plane = Plane(origin=path_spline @ 0, z_dir=path_spline % 0)
|
||||
handle_cross_section = plane * RectangleRounded(wall_thickness, 8 * MM, fillet_radius)
|
||||
|
||||
# Sweep handle cross section along path
|
||||
tea_cup += sweep(handle_cross_section, path=path_spline)
|
||||
|
||||
# assert abs(tea_cup.part.volume - 130326.77052487945) < 1e-3
|
||||
|
||||
if "show_object" in locals():
|
||||
show_object(tea_cup, name="tea cup")
|
||||
Loading…
Add table
Add a link
Reference in a new issue