mirror of
https://github.com/Theaninova/Brick-Monorail.git
synced 2026-02-04 16:12:39 +00:00
pin version
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import cadquery as cq
|
||||
from parts.rail import rail
|
||||
from parts.straight_joint import straight_joint_standoff_insert
|
||||
import presets
|
||||
import os
|
||||
|
||||
for name, params in presets.presets:
|
||||
part = rail(params)
|
||||
part = (
|
||||
straight_joint_standoff_insert(params, cq.Plane(cq.Vector(0, 0, 0)))
|
||||
if name == "standoff"
|
||||
else rail(params)
|
||||
)
|
||||
c = part.val().BoundingBox().center
|
||||
part = part.translate(c * -1)
|
||||
dir = os.path.dirname(f"{name}.x")
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from presets import presets
|
||||
from parts.rail import rail
|
||||
from parts.straight_joint import straight_joint_standoff_insert
|
||||
import cadquery as cq
|
||||
|
||||
name = "classic/C7"
|
||||
target = "solid/C7"
|
||||
|
||||
params = [params for name, params in presets if name == name][0]
|
||||
params = [params for name, params in presets if name == target][0]
|
||||
|
||||
# standoff_joint = straight_joint_standoff_insert(params, cq.Plane(cq.Vector(0, 0, 0)))
|
||||
# show_object(standoff_joint)
|
||||
show_object(rail(params))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
import math
|
||||
import units as u
|
||||
|
||||
@@ -9,27 +9,44 @@ class Params:
|
||||
to: tuple
|
||||
shell: bool
|
||||
hollow_studs: bool
|
||||
# 3D printing optimization that allows
|
||||
# for the part to be printed flush to the
|
||||
# bed, at the expense of having to glue
|
||||
standoff_flush_cut: bool
|
||||
# Instead of 3d printing the studs,
|
||||
# a pin hole is left to insert a 4274
|
||||
# technic pit with a stud.
|
||||
standoff_uses_pins: bool
|
||||
|
||||
width: float = u.studs(4)
|
||||
height = u.studs(1)
|
||||
|
||||
# Tolerance is also used in the injection moulded parts.
|
||||
# The tolerance applies to each individual side,
|
||||
# but is only subtracted once from the height.
|
||||
tolerance = 0.1
|
||||
|
||||
start_joint = True
|
||||
end_joint = True
|
||||
joint_studs = 2
|
||||
|
||||
nail_slot = True
|
||||
nail_slot_size = (u.studs(1), u.ldu(1), u.ldu(1))
|
||||
nail_slot_size = (u.studs(1), u.ldu(2), u.ldu(2))
|
||||
|
||||
connector = True
|
||||
connector_position = u.ldu(4)
|
||||
connector_width = u.ldu(8)
|
||||
connector_depth = u.ldu(1)
|
||||
connector_size = (u.ldu(2), u.ldu(7))
|
||||
|
||||
# 3D printing optimization that makes
|
||||
# functional inner corners sharper
|
||||
corner_sharpening = True
|
||||
corner_sharpening_amount = u.ldu(1)
|
||||
|
||||
shell_mid_thickness = u.stud(1)
|
||||
shell_mid_cut_thickness = u.ldu(4)
|
||||
shell_support = True
|
||||
|
||||
standoff_height = u.brick(1)
|
||||
standoff_height = u.brick(1) + u.ldu(1)
|
||||
standoff_padding = u.ldu(6)
|
||||
standoff_studs = (1, 2)
|
||||
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
import cadquery as cq
|
||||
from params import Params
|
||||
import units as u
|
||||
from parts.straight_joint import straight_joint_cut, straight_joint
|
||||
from parts.straight_joint import (
|
||||
straight_joint_cut,
|
||||
straight_joint_sharpening_cut,
|
||||
straight_joint,
|
||||
)
|
||||
from parts.shell_support import rail_shell_support
|
||||
|
||||
|
||||
def rail_body(params: Params, path: cq.Wire):
|
||||
half_height = params.height / 2
|
||||
t0 = path.tangentAt(0)
|
||||
plane = cq.Plane(path.positionAt(0), -t0.cross(cq.Vector(0, 0, 1)), t0)
|
||||
workplane = (
|
||||
cq.Workplane(plane)
|
||||
.center(0, half_height)
|
||||
.rect(params.width, params.height)
|
||||
.center(0, params.height / 2)
|
||||
.rect(params.width - params.tolerance * 2, params.height - params.tolerance * 2)
|
||||
.sweep(path)
|
||||
)
|
||||
|
||||
joint_tolerance_offset = cq.Vector(0, 0, params.tolerance)
|
||||
start_joint_plane = cq.Plane(
|
||||
path.positionAt(0) + joint_tolerance_offset, path.tangentAt(0)
|
||||
)
|
||||
end_joint_plane = cq.Plane(
|
||||
path.positionAt(1) + joint_tolerance_offset, path.tangentAt(1) * -1
|
||||
)
|
||||
|
||||
if params.start_joint:
|
||||
workplane = workplane - straight_joint_cut(
|
||||
params, cq.Plane(path.positionAt(0), path.tangentAt(0))
|
||||
)
|
||||
workplane = workplane - straight_joint_cut(params, start_joint_plane)
|
||||
|
||||
if params.end_joint:
|
||||
workplane = workplane - straight_joint_cut(
|
||||
params, cq.Plane(path.positionAt(1), path.tangentAt(1) * -1)
|
||||
)
|
||||
workplane = workplane - straight_joint_cut(params, end_joint_plane)
|
||||
|
||||
workplane = workplane.combine()
|
||||
|
||||
@@ -35,28 +42,22 @@ def rail_body(params: Params, path: cq.Wire):
|
||||
standoff_cut_depth = (
|
||||
u.studs(params.joint_studs - params.standoff_studs[0]) + shell_thickness
|
||||
)
|
||||
standoff_offset = params.standoff_height - params.height
|
||||
standoff_offset = params.standoff_height - (params.height - params.tolerance * 2)
|
||||
standoff_cut_height = (
|
||||
(standoff_offset + params.height - shell_thickness)
|
||||
(standoff_offset + (params.height - params.tolerance * 2) - shell_thickness)
|
||||
if params.shell
|
||||
else standoff_offset
|
||||
)
|
||||
standoff_cut_width = params.width - u.studs(params.standoff_studs[1])
|
||||
if params.start_joint:
|
||||
workplane = workplane + straight_joint(
|
||||
params,
|
||||
cq.Plane(
|
||||
path.positionAt(0),
|
||||
path.tangentAt(0),
|
||||
),
|
||||
)
|
||||
if params.start_joint and (params.height < params.standoff_height or params.shell):
|
||||
workplane = workplane + straight_joint(params, start_joint_plane)
|
||||
if params.start_joint and params.shell:
|
||||
cut = cq.Workplane(
|
||||
cq.Plane(
|
||||
path.positionAt(0)
|
||||
+ path.tangentAt(0) * u.studs(params.standoff_studs[0])
|
||||
start_joint_plane.origin
|
||||
+ start_joint_plane.xDir * u.studs(params.standoff_studs[0])
|
||||
+ cq.Vector(0, 0, -standoff_offset),
|
||||
path.tangentAt(0),
|
||||
start_joint_plane.xDir,
|
||||
)
|
||||
).box(
|
||||
standoff_cut_depth,
|
||||
@@ -65,20 +66,18 @@ def rail_body(params: Params, path: cq.Wire):
|
||||
centered=(False, True, False),
|
||||
)
|
||||
workplane = workplane - cut
|
||||
if params.start_joint and params.corner_sharpening:
|
||||
workplane = workplane - straight_joint_sharpening_cut(params, start_joint_plane)
|
||||
|
||||
if params.end_joint:
|
||||
workplane = workplane + straight_joint(
|
||||
params, cq.Plane(path.positionAt(1), path.tangentAt(1) * -1)
|
||||
)
|
||||
if params.end_joint and (params.height < params.standoff_height or params.shell):
|
||||
workplane = workplane + straight_joint(params, end_joint_plane)
|
||||
if params.end_joint and params.shell:
|
||||
cut = cq.Workplane(
|
||||
cq.Plane(
|
||||
(
|
||||
path.positionAt(1)
|
||||
- path.tangentAt(1) * u.studs(params.standoff_studs[0])
|
||||
)
|
||||
end_joint_plane.origin
|
||||
+ end_joint_plane.xDir * u.studs(params.standoff_studs[0])
|
||||
+ cq.Vector(0, 0, -standoff_offset),
|
||||
-path.tangentAt(1),
|
||||
end_joint_plane.xDir,
|
||||
)
|
||||
).box(
|
||||
standoff_cut_depth,
|
||||
@@ -87,6 +86,8 @@ def rail_body(params: Params, path: cq.Wire):
|
||||
centered=(False, True, False),
|
||||
)
|
||||
workplane = workplane - cut
|
||||
if params.end_joint and params.corner_sharpening:
|
||||
workplane = workplane - straight_joint_sharpening_cut(params, end_joint_plane)
|
||||
|
||||
if params.shell and params.shell_support:
|
||||
workplane = workplane + rail_shell_support(params, path)
|
||||
|
||||
@@ -6,11 +6,12 @@ import units as u
|
||||
|
||||
def rail_shell_support(params: Params, path: cq.Wire):
|
||||
t0 = path.tangentAt(0)
|
||||
tolerance_offset = cq.Vector(0, 0, params.tolerance)
|
||||
plane = cq.Plane(path.positionAt(0), -t0.cross(cq.Vector(0, 0, 1)), t0)
|
||||
support = (
|
||||
cq.Workplane(plane)
|
||||
.center(0, params.height / 2)
|
||||
.rect(params.shell_mid_thickness, params.height)
|
||||
.rect(params.shell_mid_thickness, params.height - params.tolerance * 2)
|
||||
.sweep(path)
|
||||
)
|
||||
|
||||
@@ -25,11 +26,14 @@ def rail_shell_support(params: Params, path: cq.Wire):
|
||||
|
||||
for i in range(1, support_count + 1):
|
||||
d = i / (support_count + 1)
|
||||
local_plane = cq.Plane(path.positionAt(d), path.tangentAt(d))
|
||||
local_plane = cq.Plane(path.positionAt(d) + tolerance_offset, path.tangentAt(d))
|
||||
support_square = (
|
||||
cq.Workplane(local_plane)
|
||||
.box(
|
||||
square_width, square_width, params.height, centered=(True, True, False)
|
||||
square_width,
|
||||
square_width,
|
||||
params.height - params.tolerance * 2,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
.rotateAboutCenter((0, 0, 1), 45)
|
||||
)
|
||||
@@ -40,7 +44,7 @@ def rail_shell_support(params: Params, path: cq.Wire):
|
||||
cq.Workplane(local_plane).box(
|
||||
shell_thickness,
|
||||
params.width - shell_thickness,
|
||||
params.height,
|
||||
params.height - params.tolerance * 2,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
- support_square
|
||||
@@ -50,37 +54,41 @@ def rail_shell_support(params: Params, path: cq.Wire):
|
||||
support = support - (
|
||||
cq.Workplane(plane)
|
||||
.center(0, params.height / 2)
|
||||
.rect(params.shell_mid_cut_thickness, params.height)
|
||||
.rect(params.shell_mid_cut_thickness, params.height - params.tolerance * 2)
|
||||
.sweep(path)
|
||||
)
|
||||
|
||||
for i in range(0, support_count + 1):
|
||||
d = (i + 0.5) / (support_count + 1)
|
||||
local_plane = cq.Plane(path.positionAt(d), path.tangentAt(d))
|
||||
local_plane = cq.Plane(path.positionAt(d) + tolerance_offset, path.tangentAt(d))
|
||||
support = support + (
|
||||
cq.Workplane(local_plane).box(
|
||||
shell_thickness,
|
||||
params.shell_mid_thickness - params.shell_mid_cut_thickness,
|
||||
params.height,
|
||||
params.height - params.tolerance * 2,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
)
|
||||
|
||||
if params.start_joint:
|
||||
support = support - (
|
||||
cq.Workplane(cq.Plane(path.positionAt(0), path.tangentAt(0))).box(
|
||||
cq.Workplane(
|
||||
cq.Plane(path.positionAt(0) + tolerance_offset, path.tangentAt(0))
|
||||
).box(
|
||||
u.studs(params.standoff_studs[0]),
|
||||
params.width * 2,
|
||||
params.height,
|
||||
params.height - params.tolerance * 2,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
)
|
||||
if params.end_joint:
|
||||
support = support - (
|
||||
cq.Workplane(cq.Plane(path.positionAt(1), -path.tangentAt(1))).box(
|
||||
cq.Workplane(
|
||||
cq.Plane(path.positionAt(1) + tolerance_offset, -path.tangentAt(1))
|
||||
).box(
|
||||
u.studs(params.standoff_studs[0]),
|
||||
params.width * 2,
|
||||
params.height,
|
||||
params.height - params.tolerance * 2,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,21 +1,45 @@
|
||||
import cadquery as cq
|
||||
from params import Params
|
||||
import dataclasses
|
||||
import units as u
|
||||
import math
|
||||
|
||||
|
||||
def straight_joint_cut(params: Params, plane: cq.Plane):
|
||||
return cq.Workplane(plane).box(
|
||||
workplane = cq.Workplane(plane).box(
|
||||
u.studs(params.joint_studs),
|
||||
params.width * 2,
|
||||
params.height,
|
||||
params.height - params.tolerance * 2,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
|
||||
return workplane
|
||||
|
||||
|
||||
def straight_joint_sharpening_cut(params: Params, plane: cq.Plane):
|
||||
x = u.studs(params.joint_studs)
|
||||
y = params.width / 2 - u.plate(1)
|
||||
return (
|
||||
cq.Workplane(plane)
|
||||
.pushPoints([(x, y), (x, -y)])
|
||||
.cylinder(
|
||||
params.height - params.tolerance * 2,
|
||||
params.corner_sharpening_amount / 2,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def joint_studs(params: Params, plane: cq.Plane, face: cq.Face):
|
||||
normal = face.normalAt()
|
||||
workplane = (
|
||||
cq.Workplane(cq.Plane(face.Center(), normal.cross(plane.zDir), normal))
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
face.Center() - plane.xDir * (params.tolerance / 2),
|
||||
normal.cross(plane.zDir),
|
||||
normal,
|
||||
)
|
||||
)
|
||||
.rarray(u.studs(1), u.studs(1), params.joint_studs, 1)
|
||||
.cylinder(u.stud_height(1), u.stud(0.5), centered=(True, True, False))
|
||||
)
|
||||
@@ -28,27 +52,124 @@ def joint_studs(params: Params, plane: cq.Plane, face: cq.Face):
|
||||
return workplane.vals()[0]
|
||||
|
||||
|
||||
def joint_pins(params: Params, plane: cq.Plane, face: cq.Face):
|
||||
normal = -face.normalAt()
|
||||
local_plane = cq.Plane(
|
||||
face.Center() - plane.xDir * (params.tolerance / 2),
|
||||
normal.cross(plane.zDir),
|
||||
normal,
|
||||
)
|
||||
extraction_padding = u.ldu(9)
|
||||
workplane = (
|
||||
cq.Workplane(local_plane)
|
||||
.rarray(u.studs(1), u.studs(1), params.joint_studs, 1)
|
||||
.cylinder(u.pin_shim_height(1) + u.ldu(1), u.pin_shim(1) / 2)
|
||||
.rarray(u.studs(1), u.studs(1), params.joint_studs, 1)
|
||||
.cylinder(u.studs(1), u.pin(1) / 2, centered=(True, True, False))
|
||||
.add(
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
local_plane.origin
|
||||
+ local_plane.zDir * (u.studs(1) + extraction_padding / 2)
|
||||
- cq.Vector(0, 0, u.brick(0.5)),
|
||||
local_plane.xDir,
|
||||
local_plane.zDir,
|
||||
)
|
||||
)
|
||||
.rarray(u.studs(1), u.studs(1), params.joint_studs, 1)
|
||||
.box(u.pin_clip(1), u.brick(1), u.ldu(3) + extraction_padding)
|
||||
)
|
||||
.add(
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
local_plane.origin
|
||||
+ local_plane.zDir * (u.studs(1) + extraction_padding / 2),
|
||||
local_plane.xDir,
|
||||
local_plane.zDir,
|
||||
)
|
||||
)
|
||||
.rarray(u.studs(1), u.studs(1), params.joint_studs, 1)
|
||||
.cylinder(u.ldu(3) + extraction_padding, u.pin_clip(1) / 2)
|
||||
)
|
||||
.combine()
|
||||
)
|
||||
|
||||
return workplane.vals()[0]
|
||||
|
||||
|
||||
def straight_joint_standoff_insert(params: Params, plane: cq.Plane):
|
||||
standoff_height = params.standoff_height - params.height
|
||||
joint = straight_joint(dataclasses.replace(params, standoff_flush_cut=False), plane)
|
||||
x = u.studs(params.standoff_studs[0]) / 2
|
||||
y = (
|
||||
u.studs(params.standoff_studs[1]) - (u.studs(1) - u.stud(1))
|
||||
) / 2 + params.standoff_padding / 2
|
||||
guides = (
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
plane.origin - (plane.zDir * standoff_height), plane.xDir, plane.zDir
|
||||
)
|
||||
)
|
||||
.pushPoints([(x, y), (x, -y)])
|
||||
.box(
|
||||
u.studs(params.standoff_studs[0]) - params.standoff_padding,
|
||||
params.standoff_padding / 2,
|
||||
u.stud_height(2),
|
||||
centered=(True, True, False),
|
||||
)
|
||||
) - joint
|
||||
|
||||
return (
|
||||
joint.intersect(
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
plane.origin - (plane.zDir * standoff_height / 2),
|
||||
plane.xDir,
|
||||
plane.zDir,
|
||||
)
|
||||
).box(
|
||||
u.studs(params.standoff_studs[0]) * 2,
|
||||
params.width,
|
||||
standoff_height,
|
||||
)
|
||||
)
|
||||
+ guides
|
||||
)
|
||||
|
||||
|
||||
def straight_joint(params: Params, plane: cq.Plane):
|
||||
height = params.height - params.tolerance * 2
|
||||
half_width = (params.width - u.plate(2)) / 2
|
||||
workplane = (
|
||||
cq.Workplane(plane)
|
||||
.center(params.tolerance, 0)
|
||||
.box(
|
||||
u.studs(params.joint_studs),
|
||||
u.studs(params.joint_studs) - params.tolerance,
|
||||
params.width - u.plate(2),
|
||||
params.height,
|
||||
height,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
.faces(
|
||||
)
|
||||
|
||||
if params.standoff_uses_pins:
|
||||
workplane = workplane.faces(
|
||||
cq.selectors.SumSelector(
|
||||
cq.selectors.DirectionNthSelector(plane.yDir, 1),
|
||||
cq.selectors.DirectionNthSelector(plane.yDir, 0),
|
||||
)
|
||||
).each(
|
||||
lambda f: joint_pins(params, plane, f),
|
||||
combine="s",
|
||||
)
|
||||
.each(
|
||||
else:
|
||||
workplane = workplane.faces(
|
||||
cq.selectors.SumSelector(
|
||||
cq.selectors.DirectionNthSelector(plane.yDir, 1),
|
||||
cq.selectors.DirectionNthSelector(plane.yDir, 0),
|
||||
)
|
||||
).each(
|
||||
lambda f: joint_studs(params, plane, f),
|
||||
useLocalCoordinates=True,
|
||||
)
|
||||
)
|
||||
|
||||
if params.nail_slot:
|
||||
workplane = (
|
||||
@@ -56,8 +177,8 @@ def straight_joint(params: Params, plane: cq.Plane):
|
||||
.sketch()
|
||||
.push(
|
||||
[
|
||||
(0, half_width),
|
||||
(0, -half_width),
|
||||
(params.tolerance / -2, half_width),
|
||||
(params.tolerance / -2, -half_width),
|
||||
]
|
||||
)
|
||||
.rect(
|
||||
@@ -68,25 +189,14 @@ def straight_joint(params: Params, plane: cq.Plane):
|
||||
.cutBlind(-params.nail_slot_size[2])
|
||||
)
|
||||
|
||||
if params.height < params.standoff_height:
|
||||
workplane = (
|
||||
workplane.faces("<Z")
|
||||
.rect(
|
||||
u.studs(params.joint_studs),
|
||||
params.width - u.plate(2),
|
||||
)
|
||||
.extrude(params.height - params.standoff_height)
|
||||
)
|
||||
else:
|
||||
workplane = (
|
||||
workplane.faces("<Z")
|
||||
.rect(
|
||||
-u.studs(params.standoff_studs[0]),
|
||||
u.studs(params.standoff_studs[1]),
|
||||
centered=(False, True),
|
||||
)
|
||||
.cutBlind(params.standoff_height - params.height)
|
||||
workplane = (
|
||||
workplane.faces("<Z")
|
||||
.rect(
|
||||
u.studs(params.joint_studs) - params.tolerance,
|
||||
params.width - u.plate(2),
|
||||
)
|
||||
.extrude(height - params.standoff_height)
|
||||
)
|
||||
|
||||
if params.connector:
|
||||
face: cq.Face = workplane.faces(
|
||||
@@ -95,60 +205,108 @@ def straight_joint(params: Params, plane: cq.Plane):
|
||||
normal = face.normalAt()
|
||||
face_plane = cq.Plane(face.Center(), normal.cross(plane.zDir), normal)
|
||||
x_pos = (
|
||||
params.width - u.plate(2) - params.connector_width
|
||||
params.width - u.plate(2) - params.connector_size[1]
|
||||
) / 2 - params.connector_position
|
||||
full_height = face.BoundingBox().zlen
|
||||
|
||||
positive = (
|
||||
cq.Workplane(face_plane)
|
||||
.center(-x_pos, 0)
|
||||
.box(
|
||||
params.connector_width,
|
||||
face.BoundingBox().zlen,
|
||||
params.connector_depth * 2,
|
||||
params.connector_size[1] - params.tolerance,
|
||||
full_height,
|
||||
(params.connector_size[0] - params.tolerance) * 2,
|
||||
)
|
||||
)
|
||||
negative = (
|
||||
cq.Workplane(face_plane)
|
||||
.center(x_pos, 0)
|
||||
.box(
|
||||
params.connector_width,
|
||||
face.BoundingBox().zlen,
|
||||
params.connector_depth * 2,
|
||||
params.connector_size[1],
|
||||
full_height,
|
||||
params.connector_size[0] * 2,
|
||||
)
|
||||
)
|
||||
workplane = workplane + positive - negative
|
||||
if params.corner_sharpening:
|
||||
cuts = (
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
cq.Vector(
|
||||
face_plane.origin.x,
|
||||
face_plane.origin.y,
|
||||
face.BoundingBox().zmin,
|
||||
),
|
||||
plane.xDir,
|
||||
plane.zDir,
|
||||
)
|
||||
)
|
||||
.pushPoints(
|
||||
[
|
||||
(
|
||||
params.connector_size[0],
|
||||
x_pos + params.connector_size[1] / 2,
|
||||
),
|
||||
(
|
||||
params.connector_size[0],
|
||||
x_pos - params.connector_size[1] / 2,
|
||||
),
|
||||
(
|
||||
0,
|
||||
-x_pos + (params.connector_size[1]) / 2,
|
||||
),
|
||||
(
|
||||
0,
|
||||
-x_pos - (params.connector_size[1]) / 2,
|
||||
),
|
||||
]
|
||||
)
|
||||
.cylinder(
|
||||
full_height,
|
||||
params.corner_sharpening_amount / 2,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
)
|
||||
workplane = workplane - cuts
|
||||
|
||||
if params.height < params.standoff_height:
|
||||
h = params.standoff_height - params.height
|
||||
d = (
|
||||
params.width - u.studs(params.standoff_studs[1]) - params.standoff_padding
|
||||
) / 2
|
||||
x = (params.width - d) / 2
|
||||
workplane = workplane - (
|
||||
cq.Workplane(plane)
|
||||
.pushPoints(
|
||||
[(-params.connector_depth, x, -h), (-params.connector_depth, -x, -h)]
|
||||
)
|
||||
.box(
|
||||
u.studs(params.joint_studs) + params.connector_depth,
|
||||
d,
|
||||
h,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
h = params.standoff_height - height
|
||||
d = (params.width - u.studs(params.standoff_studs[1]) - params.standoff_padding) / 2
|
||||
x = (params.width - d) / 2
|
||||
workplane = workplane - (
|
||||
cq.Workplane(plane)
|
||||
.pushPoints(
|
||||
[
|
||||
(-params.connector_size[1], x, -h),
|
||||
(-params.connector_size[1], -x, -h),
|
||||
]
|
||||
)
|
||||
.box(
|
||||
u.studs(params.joint_studs) + params.connector_size[1],
|
||||
d,
|
||||
h,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
)
|
||||
|
||||
shell_thickness = (u.studs(1) - u.stud(1)) / 2
|
||||
stud_slot_plane = cq.Plane(
|
||||
plane.origin + cq.Vector(0, 0, params.height - shell_thickness),
|
||||
plane.origin - cq.Vector(0, 0, params.standoff_height - height),
|
||||
plane.xDir,
|
||||
-plane.zDir,
|
||||
plane.zDir,
|
||||
)
|
||||
stud_slot_depth = (
|
||||
u.stud_height(2)
|
||||
if params.standoff_uses_pins
|
||||
else params.standoff_height - shell_thickness
|
||||
)
|
||||
|
||||
stud_slot = (
|
||||
cq.Workplane(stud_slot_plane)
|
||||
.center(u.studs(params.standoff_studs[0] / 2), 0)
|
||||
.box(
|
||||
u.studs(params.standoff_studs[0]) - params.standoff_padding,
|
||||
u.studs(params.standoff_studs[1]),
|
||||
params.height,
|
||||
stud_slot_depth,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
)
|
||||
@@ -162,9 +320,47 @@ def straight_joint(params: Params, plane: cq.Plane):
|
||||
.box(
|
||||
params.standoff_padding / 2,
|
||||
(u.studs(1) - u.stud(1)) / 2,
|
||||
params.height,
|
||||
stud_slot_depth,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
)
|
||||
|
||||
points = [
|
||||
(u.studs(i), j - params.standoff_studs[1] / 2)
|
||||
for i in range(0, params.standoff_studs[0] + 1)
|
||||
for j in range(1, params.standoff_studs[1])
|
||||
]
|
||||
r = (math.sqrt(2 * u.studs(1) ** 2) - u.stud(1)) / 2
|
||||
|
||||
workplane = workplane + (
|
||||
cq.Workplane(stud_slot_plane)
|
||||
.pushPoints(points)
|
||||
.cylinder(stud_slot_depth, r, centered=(True, True, False))
|
||||
.intersect(
|
||||
cq.Workplane(stud_slot_plane)
|
||||
.center(params.tolerance, 0)
|
||||
.box(
|
||||
u.studs(params.standoff_studs[0]) - params.tolerance,
|
||||
u.studs(params.standoff_studs[1]),
|
||||
stud_slot_depth,
|
||||
centered=(False, True, False),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if params.standoff_flush_cut:
|
||||
workplane = workplane.intersect(
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
plane.origin + (plane.zDir * height / 2),
|
||||
plane.xDir,
|
||||
plane.zDir,
|
||||
)
|
||||
).box(
|
||||
u.studs(params.joint_studs) * 2,
|
||||
params.width,
|
||||
height,
|
||||
)
|
||||
)
|
||||
|
||||
return workplane
|
||||
|
||||
@@ -21,22 +21,32 @@ def rail_teeth(params: Params, path: cq.Wire):
|
||||
path_wire_length / (params.teeth_width + params.teeth_spacing)
|
||||
)
|
||||
t0 = path.tangentAt(0)
|
||||
z = params.height - params.tolerance + params.teeth_height / 2
|
||||
|
||||
workplane = (
|
||||
cq.Workplane(cq.Plane(path.positionAt(0), -t0.cross(cq.Vector(0, 0, 1)), t0))
|
||||
.center(0, params.height + params.teeth_height / 2)
|
||||
.center(0, z)
|
||||
.rect(params.teeth_inner_width, params.teeth_height)
|
||||
.sweep(path)
|
||||
)
|
||||
|
||||
for d in [0, 1]:
|
||||
workplane = workplane - (
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
path.positionAt(d) + cq.Vector(0, 0, z),
|
||||
path.tangentAt(d),
|
||||
),
|
||||
).box(params.tolerance * 2, params.teeth_outer_width, params.teeth_height)
|
||||
)
|
||||
|
||||
for i in range(1, teeth_count + 1):
|
||||
d = (i - 0.5) / (teeth_count)
|
||||
workplane = workplane.add(
|
||||
tooth(
|
||||
params,
|
||||
cq.Plane(
|
||||
path.positionAt(d)
|
||||
+ cq.Vector(0, 0, params.height + params.teeth_height / 2),
|
||||
path.positionAt(d) + cq.Vector(0, 0, z),
|
||||
path.tangentAt(d),
|
||||
),
|
||||
)
|
||||
|
||||
121
src/presets.py
121
src/presets.py
@@ -7,6 +7,8 @@ presets = [
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=True,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(1), u.studs(7)),
|
||||
),
|
||||
@@ -16,6 +18,8 @@ presets = [
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=True,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(5), u.studs(15)),
|
||||
),
|
||||
@@ -25,6 +29,8 @@ presets = [
|
||||
# Params(
|
||||
# shell=True,
|
||||
# hollow_studs=True,
|
||||
# standoff_flush_cut=False,
|
||||
# standoff_uses_pins=False,
|
||||
# radius=u.studs(25),
|
||||
# to=(u.studs(0), u.studs(4)),
|
||||
# ),
|
||||
@@ -34,6 +40,8 @@ presets = [
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=True,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
@@ -43,15 +51,30 @@ presets = [
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=True,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"standoff",
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid/C7",
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(1), u.studs(7)),
|
||||
),
|
||||
@@ -61,6 +84,8 @@ presets = [
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(5), u.studs(15)),
|
||||
),
|
||||
@@ -70,6 +95,8 @@ presets = [
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(4)),
|
||||
),
|
||||
@@ -79,6 +106,8 @@ presets = [
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
@@ -88,96 +117,8 @@ presets = [
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"classic_solid_studs/C7",
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(1), u.studs(7)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"classic_solid_studs/C15",
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(5), u.studs(15)),
|
||||
),
|
||||
),
|
||||
# (
|
||||
# "classic_solid_studs/S4",
|
||||
# Params(
|
||||
# shell=True,
|
||||
# hollow_studs=False,
|
||||
# radius=u.studs(25),
|
||||
# to=(u.studs(0), u.studs(4)),
|
||||
# ),
|
||||
# ),
|
||||
(
|
||||
"classic_solid_studs/S5",
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"classic_solid_studs/S10",
|
||||
Params(
|
||||
shell=True,
|
||||
hollow_studs=False,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_hollow_studs/C7",
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(1), u.studs(7)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_hollow_studs/C15",
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(5), u.studs(15)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_hollow_studs/S4",
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(4)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_hollow_studs/S5",
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_hollow_studs/S10",
|
||||
Params(
|
||||
shell=False,
|
||||
hollow_studs=True,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
|
||||
18
src/units.py
18
src/units.py
@@ -6,8 +6,24 @@ def stud(value):
|
||||
return value * ldu(12)
|
||||
|
||||
|
||||
def pin(value):
|
||||
return value * ldu(12)
|
||||
|
||||
|
||||
def pin_shim(value):
|
||||
return value * ldu(16)
|
||||
|
||||
|
||||
def pin_shim_height(value):
|
||||
return value * ldu(3)
|
||||
|
||||
|
||||
def pin_clip(value):
|
||||
return value * ldu(14)
|
||||
|
||||
|
||||
def stud_height(value):
|
||||
return value * ldu(4)
|
||||
return value * ldu(4.5)
|
||||
|
||||
|
||||
def studs(value):
|
||||
|
||||
Reference in New Issue
Block a user