vectorized location multiplication

This commit is contained in:
Bernhard 2023-03-27 22:15:25 +02:00
parent f871a73e34
commit 15bdaa05d4
7 changed files with 46 additions and 57 deletions

View file

@ -28,51 +28,51 @@ 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(
length=block_length,
width=block_width,
height=wall_thickness,
align=(Align.CENTER, Align.CENTER, Align.MIN),
)
# 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,
align=(Align.CENTER, Align.CENTER, Align.MIN),
)
# Create a workplane on the top of the block
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):
lego += (
plane
* loc
* Cylinder(
radius=pip_diameter / 2,
height=pip_height,
align=(Align.CENTER, Align.CENTER, Align.MIN),
)
locs = GridLocations(lego_unit_size, lego_unit_size, pip_count, 2)
lego += (
plane
* locs
* Cylinder(
radius=pip_diameter / 2,
height=pip_height,
align=(Align.CENTER, Align.CENTER, Align.MIN),
)
)
if "show_object" in locals():
show_object(lego, name="lego")