Loading TechIDaily…
Loading TechIDaily…
Sandflow / Industrial
Hosted on Hugging Face · Runtime not tested

Categories aid discovery; they are not runtime certifications.
Download the complete package with its dependencies.
Browse package on HF ↗Parametric Python program with 2 kinematic joints (UsdPhysics). Constructed for autonomous simulation and LLM synthesis.
import math
import sand3d as s3d
def eyeglasses():
part_a = part_a_body()
part_c_body = spinning_body(part_a, class="tok-string">"part_c_body", x=-65.79, y=2.82, z=15.72, rx=90, ry=70)
part_b_body = left_temple(part_c_body, class="tok-string">"part_b_body", x=48.6, y=133.52, rz=145)
return s3d.assembly(class="tok-string">"eyeglasses", part_a, part_c_body, part_b_body)
def spinning_body(parent, name, x=0, y=0, z=0, rx=0, ry=0, rz=0):
frame = s3d.local(parent, x, y, z, rx, ry, rz)
part_c_body = s3d.at(part_c_body_fn(fclass="tok-string">"{name}_piece"), on=frame)
s3d.joint(fclass="tok-string">"{name}_spin", part_c_body, frame, kind=class="tok-string">"continuous")
return part_c_body
def left_temple(parent, name, x=0, y=0, z=0, rx=0, ry=0, rz=0):
frame = s3d.local(parent, x, y, z, rx, ry, rz)
part_b_body = s3d.at(part_b_body_fn(fclass="tok-string">"{name}_piece"), on=frame)
s3d.joint(fclass="tok-string">"{name}_spin", part_b_body, frame, kind=class="tok-string">"continuous")
return part_b_body
def part_a_body():
piece = s3d.transform(part_a(class="tok-string">"part_a_body_piece"), x=-87.98, y=-2.33, z=74.5, ry=70)
return s3d.group(class="tok-string">"part_a_body", piece)
def part_c_body_fn(name):
piece = s3d.transform(part_c(name.replace(class="tok-string">"_piece", class="tok-string">"")), x=30.64, y=64.45, z=2.8, rx=-90, rz=70)
return s3d.group(name.replace(class="tok-string">"_piece", class="tok-string">""), piece)
def part_b_body_fn(name):
piece = s3d.transform(part_b(name.replace(class="tok-string">"_piece", class="tok-string">"")), x=62.83, y=-0.75, z=5.15, rx=-90)
return s3d.group(name.replace(class="tok-string">"_piece", class="tok-string">""), piece)
def part_a(
name,
length=130.16,
width=29.51,
thick=5.92,
outer_r=30,
inner_r=20,
bend_x=-27.08,
outer_y=-19.36,
inner_y=-14.85,
arm_t=2.6,
hinge_d=4.4,
hinge_pitch=6.8,
bore_d=1,
bend_angle=140,
tip_length=9,
edge_r=1,
):
tangent = (
bend_x + inner_r * math.cos(math.radians(bend_angle)),
inner_y + inner_r * math.sin(math.radians(bend_angle)),
)
outline = s3d.poly(
[
(-length / 2, -width / 2 + edge_r),
(-length / 2 + edge_r, -width / 2),
(-length / 2 + tip_length, -width / 2),
tangent,
s3d.arc(center=(bend_x, inner_y), r=inner_r, start=bend_angle, end=90),
(length / 2, inner_y + inner_r),
(length / 2, width / 2),
(bend_x, outer_y + outer_r),
s3d.arc(center=(bend_x, outer_y), r=outer_r, start=90, end=bend_angle),
]
)
arm = s3d.extrude(name, outline, arm_t, both=True)
arm = s3d.fillet(arm, edge_r, edges=class="tok-string">"top bottom")
arm = s3d.at(arm, z=-thick / 2 + arm_t / 2)
return add_hinge(arm, length / 2 - hinge_d / 2, width / 2, thick, hinge_d, hinge_pitch, bore_d, edge_r)
def add_hinge(arm, x, y, thick, d, pitch, bore, t):
ear = s3d.extrude(
class="tok-string">"ear",
s3d.poly(
[(-d * 2, -thick / 2), (d / 2, -thick / 2), (d / 2, 0), s3d.arc(center=(0, 0), r=d / 2, start=0, end=130)]
),
t,
)
ear = s3d.hole(ear, bore, on=ear.face(class="tok-string">"top"))
ear = s3d.at(ear, rx=90)
ears = s3d.at(ear, on=s3d.grid(1, 2, 0, pitch), x=x, y=y - pitch / 2, z=thick / 2 - d / 2)
return s3d.join(arm, ears)
def part_b(name, length=130.16, width=29.51, thickness=5.92, skin=2.6, edge_r=1, hinge_d=4.4, bore_d=1.75, pitch=6.8):
half = length / 2
bottom = -thickness / 2
outline = s3d.poly(
[
(-half, width / 2),
(27.08, 10.64),
s3d.spline([(27.08, 10.64), (36, 9), (43, 5), (55.16, -5.47)], tangents=((1, 0), (0.75, -0.66))),
(half, -12.5),
(half, -14),
(61.34, -14.33),
(40.3, 0.2),
s3d.spline([(40.3, 0.2), (34, 3.9), (27.08, 5.15)], tangents=((-0.75, 0.66), (-1, 0))),
(-half, 5.15),
]
)
body = s3d.at(s3d.extrude(name, outline, skin), z=bottom)
s3d.fillet(body, edge_r, edges=class="tok-string">"top bottom")
return hinge_ears(body, half, bottom, skin, hinge_d, bore_d, pitch)
def hinge_ears(body, half, bottom, skin, hinge_d, bore_d, pitch):
x = -half + hinge_d / 2
z = 0.75
profile = s3d.poly(
[
(x - hinge_d / 2, bottom),
(x + 5.72, bottom),
(x + 5.72, bottom + skin),
(x + hinge_d / 2, z),
s3d.arc(center=(x, z), r=hinge_d / 2, start=0, end=180),
]
)
ear = s3d.extrude(class="tok-string">"hinge", profile, 2.3)
ear = s3d.at(ear, rx=90, y=7.45)
other = s3d.transform(s3d.copy(ear), y=pitch)
s3d.join(body, ear, other)
s3d.hole(body, bore_d, on=s3d.Frame((x, 16, z), normal=(0, -1, 0)))
return body
def part_c(
name, w=148.07, d=40.86, h=17.89, rim=3, bridge=14, lens=56, brow=17, heel=60, hinge_d=3.96, bore=1.75, hinge_y=7.2
):
half = frame_half(name, w / 2, d / 2, rim, bridge / 2, lens, brow, heel)
other = s3d.transform(s3d.copy(half), mirror=class="tok-string">"x")
frame = s3d.join(half, other)
lug = hinge(class="tok-string">"hinge", hinge_d, bore, rim + 1)
lug = s3d.at(lug, x=w / 2 - rim, y=hinge_y, z=h / 2 - hinge_d / 2)
stem = s3d.at(
s3d.box(class="tok-string">"hinge_root", hinge_d, rim + 1, h / 2 - hinge_d / 2), x=w / 2 - rim, y=hinge_y, z=-rim / 2 + rim / 12
)
rest = nose_rest(bridge / 2, rim, h / 2 - hinge_d / 2)
s3d.join(
frame,
lug,
stem,
rest,
s3d.transform(s3d.copy(lug), mirror=class="tok-string">"x"),
s3d.transform(s3d.copy(stem), mirror=class="tok-string">"x"),
s3d.transform(s3d.copy(rest), mirror=class="tok-string">"x"),
)
return frame
def frame_half(name, reach, depth, rim, neck, lens, brow, heel):
outline = s3d.spline(
[
(0, depth - neck),
(brow, depth - rim / 2),
(reach / 2, depth),
(heel, brow),
(reach - rim / 2, depth - neck),
(reach - 2 * rim, neck / 2),
(heel + rim, -depth / 2),
(heel, -brow),
(lens, -depth + rim / 4),
(reach / 2, -depth + rim / 4),
(brow, -brow),
(neck + rim, -depth / 2),
(neck, neck),
(0, depth - neck - rim),
],
closed=True,
)
half = s3d.at(s3d.extrude(name, outline, rim), z=-rim / 2 + rim / 12)
opening = s3d.spline(
[
(neck + rim, depth - neck),
(brow + rim, brow),
(reach / 2, depth - rim),
(heel, depth - neck - rim),
(heel + rim, neck),
(heel + rim, -brow + rim),
(lens, -depth + rim),
(reach / 2, -depth + rim),
(brow, -brow + rim),
(neck + rim, 0),
],
closed=True,
)
s3d.pocket(half, opening, on=half.face(class="tok-string">"top"))
return half
def hinge(name, diameter, bore, length):
lug = s3d.extrude(name, s3d.circle(diameter), length, both=True)
s3d.hole(lug, bore)
return s3d.at(lug, rx=90)
def nose_rest(neck, rim, height):
path = s3d.spline([(neck + rim, 0), (neck + rim / 2, neck / 2), (neck, neck)], tangents=((0, 1), (0, 1)))
rest = s3d.extrude(class="tok-string">"nose_rest", s3d.stroke(path, rim), height - rim / 2)
return s3d.at(rest, z=rim / 2)🚀 Sand3D Modeling Engine: Open Interactive Sand3D Explorer Space ↗
Sandflow Sand3D Library; CC-BY-4.0
Hosted on Hugging Face: SZFSPC/techidaily-resourcesba1baf9d89ddf57433d7c47cb461f6d8883067a1
Revision: ba1baf9d89ddf57433d7c47cb461f6d8883067a1
licenseSHA-256:
commercialPermittedSHA-256:
notesSHA-256: