add grid and round_box
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .globals import SEGMENTS
|
||||
@@ -0,0 +1,38 @@
|
||||
import solid as scad
|
||||
from .globals import *
|
||||
|
||||
|
||||
def grid(
|
||||
x: float,
|
||||
y: float,
|
||||
w: float = 3,
|
||||
h: float = 1.5,
|
||||
fillet: bool = False,
|
||||
dim: float = 59,
|
||||
):
|
||||
|
||||
if w > h * 2:
|
||||
out = scad.polygon([[0, 0], [w / 2, 0], [w / 2 - h, h], [0, h]])
|
||||
else:
|
||||
out = scad.polygon([[0, 0], [w / 2, 0], [0, h]])
|
||||
out = scad.linear_extrude(dim)(out)
|
||||
out = scad.rotate([90, 0, 90])(out)
|
||||
|
||||
if fillet:
|
||||
scallop = scad.cube([dim - 2 * h - (w - 2 * h), 0.0001, 0.0001])
|
||||
scallop = scad.minkowski()(scallop, scad.sphere(r=h, segments=SEGMENTS))
|
||||
scallop += scad.rotate([0, -90, 0])(scallop) + scad.translate([dim - w, 0, 0])(
|
||||
scad.rotate([0, -90, 0])(scallop)
|
||||
)
|
||||
scallop = scad.translate([w / 2, w / 2, h])(scallop)
|
||||
out -= scallop
|
||||
|
||||
out += scad.translate([0, dim, 0])(scad.rotate([0, 0, -90])(out))
|
||||
out += scad.translate([dim, dim, 0])(scad.rotate([0, 0, 180])(out))
|
||||
|
||||
result = out
|
||||
for dx in range(x):
|
||||
for dy in range(y):
|
||||
result += scad.translate([dim * dx, dim * dy, 0])(out)
|
||||
|
||||
return result
|
||||
@@ -0,0 +1 @@
|
||||
SEGMENTS = 36
|
||||
@@ -0,0 +1,10 @@
|
||||
import solid as s
|
||||
import numpy as np
|
||||
from .globals import *
|
||||
|
||||
|
||||
def round_box(x, y, z, r):
|
||||
box = s.cube(np.array([x, y, z]) - r * 2)
|
||||
wall = s.sphere(r=r, segments=SEGMENTS)
|
||||
|
||||
return s.translate([r, r, r])(s.minkowski()(box, wall))
|
||||
Reference in New Issue
Block a user