mirror of
https://github.com/Theaninova/Brick-Monorail.git
synced 2026-07-27 07:14:41 +00:00
feat: better options
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
import cadquery as cq
|
||||
from parts.rail import rail
|
||||
from parts.rail import rail, rail_support
|
||||
from parts.straight_joint import straight_joint_standoff_insert
|
||||
import presets
|
||||
import os
|
||||
@@ -8,7 +8,7 @@ for name, params in presets.presets:
|
||||
part = (
|
||||
straight_joint_standoff_insert(params, cq.Plane(cq.Vector(0, 0, 0)))
|
||||
if name == "standoff"
|
||||
else rail(params)
|
||||
else (rail_support(params) if name.endswith("support") else rail(params))
|
||||
)
|
||||
c = part.val().BoundingBox().center
|
||||
part = part.translate(c * -1)
|
||||
|
||||
+12
-3
@@ -1,12 +1,21 @@
|
||||
from presets import presets
|
||||
from parts.rail import rail
|
||||
from parts.rail import rail, rail_support
|
||||
from parts.straight_joint import straight_joint_standoff_insert
|
||||
from parts.switch import switch
|
||||
from parts.teeth import compliant_teeth
|
||||
import units as u
|
||||
import cadquery as cq
|
||||
|
||||
target = "solid/C7"
|
||||
target = "solid_support/C7"
|
||||
|
||||
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))
|
||||
# show_object(switch(params))
|
||||
# teeth = compliant_teeth(params, u.studs(10))
|
||||
# cq.exporters.export(teeth, f"STEPs/compliant_teeth.step")
|
||||
# show_object(teeth)
|
||||
|
||||
|
||||
show_object(rail(params).add(rail_support(params)))
|
||||
|
||||
@@ -51,6 +51,7 @@ class Params:
|
||||
standoff_padding = u.ldu(6)
|
||||
standoff_studs = (1, 2)
|
||||
|
||||
teeth = True
|
||||
teeth_height = u.ldu(8)
|
||||
teeth_width = u.ldu(3.5) # 75% is correct but this leaves 0.6mm on the outside
|
||||
teeth_spacing = math.pi / 2
|
||||
|
||||
@@ -54,7 +54,6 @@ def rail_body(params: Params, path: cq.Wire):
|
||||
standoff_cut_width = params.width - u.studs(params.standoff_studs[1])
|
||||
if params.start_joint:
|
||||
workplane = workplane + straight_joint(params, start_joint_plane)
|
||||
if params.start_joint and params.shell:
|
||||
cut = cq.Workplane(
|
||||
cq.Plane(
|
||||
start_joint_plane.origin
|
||||
@@ -74,7 +73,6 @@ def rail_body(params: Params, path: cq.Wire):
|
||||
|
||||
if params.end_joint:
|
||||
workplane = workplane + straight_joint(params, end_joint_plane)
|
||||
if params.end_joint and params.shell:
|
||||
cut = cq.Workplane(
|
||||
cq.Plane(
|
||||
end_joint_plane.origin
|
||||
|
||||
+73
-1
@@ -37,4 +37,76 @@ def rail(params: Params):
|
||||
.ctx.pendingEdges
|
||||
)
|
||||
|
||||
return (rail_body(params, path) + rail_teeth(params, path)).combine()
|
||||
rail = rail_body(params, path)
|
||||
if params.teeth:
|
||||
rail = rail + rail_teeth(params, path)
|
||||
return rail
|
||||
|
||||
|
||||
def rail_support_joint(
|
||||
workplane: cq.Workplane, plane: cq.Plane, params: Params
|
||||
) -> cq.Workplane:
|
||||
standoff_offset = params.standoff_height - (params.height - params.tolerance * 2)
|
||||
workplane = workplane + cq.Workplane(
|
||||
cq.Plane(
|
||||
plane.origin - (standoff_offset) / 2 * plane.zDir,
|
||||
plane.xDir,
|
||||
plane.zDir,
|
||||
)
|
||||
).box(
|
||||
params.connector_size[0] * 2,
|
||||
params.width - u.plate(2),
|
||||
standoff_offset,
|
||||
)
|
||||
|
||||
cut = cq.Workplane(plane).box(
|
||||
(u.studs(2) + params.tolerance * 3) * 2,
|
||||
u.studs(params.standoff_studs[1])
|
||||
+ params.standoff_padding
|
||||
+ params.tolerance * 4,
|
||||
params.height,
|
||||
) - cq.Workplane(plane).center(
|
||||
u.studs(params.standoff_studs[0]) + params.tolerance * 2, 0
|
||||
).box(
|
||||
(u.studs(2) + params.tolerance * 2) * 2 - u.studs(params.standoff_studs[0]),
|
||||
u.studs(params.standoff_studs[1]) - params.tolerance * 4,
|
||||
params.height,
|
||||
centered=(False, True, True),
|
||||
)
|
||||
|
||||
return workplane - cut
|
||||
|
||||
|
||||
def rail_support(params: Params):
|
||||
path = cq.Wire.assembleEdges(
|
||||
(
|
||||
cq.Workplane("XY").polyline([(0, 0), params.to])
|
||||
if params.to[0] == 0
|
||||
else cq.Workplane("XY").radiusArc(params.to, params.radius)
|
||||
).ctx.pendingEdges
|
||||
)
|
||||
|
||||
standoff_offset = params.standoff_height - (params.height - params.tolerance * 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, -(standoff_offset) / 2 + params.tolerance)
|
||||
.rect(params.width - params.tolerance * 2, standoff_offset)
|
||||
.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 = rail_support_joint(workplane, start_joint_plane, params)
|
||||
if params.end_joint:
|
||||
workplane = rail_support_joint(workplane, end_joint_plane, params)
|
||||
return workplane
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
from parts.rail import rail
|
||||
import cadquery as cq
|
||||
import units as u
|
||||
import math
|
||||
import dataclasses
|
||||
from params import Params
|
||||
|
||||
|
||||
def switch(params: Params):
|
||||
straight_length = u.studs(20)
|
||||
move_dist = u.studs(3)
|
||||
cut_tolerance = params.teeth_spacing / 2
|
||||
|
||||
straight_params = dataclasses.replace(params, to=(u.studs(0), straight_length))
|
||||
# straight_params.teeth = False
|
||||
curve_params = dataclasses.replace(params, to=(u.studs(5), u.studs(15)))
|
||||
# curve_params.teeth = False
|
||||
cut_start = u.studs(2)
|
||||
cut_end = math.sqrt(params.radius**2 - (params.radius - move_dist) ** 2)
|
||||
cut_length = cut_end - cut_start
|
||||
|
||||
straight_rail = rail(straight_params)
|
||||
curved_rail = rail(curve_params)
|
||||
|
||||
# plate slot
|
||||
curved_rail = curved_rail - (
|
||||
cq.Workplane("XY")
|
||||
.pushPoints(
|
||||
[
|
||||
(
|
||||
params.width / 2 - u.plate(1) - params.tolerance * 2,
|
||||
straight_length - u.studs(params.joint_studs),
|
||||
0,
|
||||
)
|
||||
]
|
||||
)
|
||||
.box(
|
||||
u.stud_height(1) + u.plate(1),
|
||||
u.studs(params.joint_studs),
|
||||
params.height,
|
||||
centered=(False, False, False),
|
||||
)
|
||||
)
|
||||
|
||||
# cut out teeth
|
||||
tolerance_cut = (
|
||||
cq.Workplane("XY")
|
||||
.pushPoints(
|
||||
[
|
||||
(0, cut_start, params.height - params.tolerance),
|
||||
(0, cut_end, params.height - params.tolerance),
|
||||
]
|
||||
)
|
||||
.box(
|
||||
params.width * 3,
|
||||
cut_tolerance,
|
||||
params.height,
|
||||
centered=(True, True, False),
|
||||
)
|
||||
)
|
||||
curved_rail = curved_rail - tolerance_cut
|
||||
straight_rail = straight_rail - tolerance_cut
|
||||
|
||||
straight_teeth_cut = (
|
||||
cq.Workplane("XY")
|
||||
.pushPoints(
|
||||
[
|
||||
(
|
||||
0,
|
||||
cut_start,
|
||||
params.height - params.tolerance,
|
||||
)
|
||||
]
|
||||
)
|
||||
.box(
|
||||
params.width * 3,
|
||||
cut_length,
|
||||
params.height,
|
||||
centered=(True, False, False),
|
||||
)
|
||||
)
|
||||
straight_teeth = straight_rail.intersect(straight_teeth_cut)
|
||||
straight_rail = straight_rail - straight_teeth_cut
|
||||
|
||||
curved_teeth_cut = (
|
||||
cq.Workplane("XY")
|
||||
.pushPoints(
|
||||
[
|
||||
(
|
||||
0,
|
||||
0,
|
||||
params.height - params.tolerance,
|
||||
)
|
||||
]
|
||||
)
|
||||
.box(
|
||||
params.width * 3,
|
||||
cut_length + cut_start,
|
||||
params.height,
|
||||
centered=(True, False, False),
|
||||
)
|
||||
)
|
||||
curved_teeth = curved_rail.intersect(curved_teeth_cut)
|
||||
curved_rail = curved_rail - curved_teeth_cut
|
||||
|
||||
rails = straight_rail + curved_rail
|
||||
|
||||
return rails
|
||||
+46
-3
@@ -1,6 +1,7 @@
|
||||
import cadquery as cq
|
||||
from params import Params
|
||||
import math
|
||||
import units as u
|
||||
|
||||
|
||||
def tooth(params: Params, plane: cq.Plane):
|
||||
@@ -17,9 +18,7 @@ def tooth(params: Params, plane: cq.Plane):
|
||||
|
||||
def rail_teeth(params: Params, path: cq.Wire):
|
||||
path_wire_length = path.Length()
|
||||
teeth_count = math.floor(
|
||||
path_wire_length / params.teeth_spacing
|
||||
)
|
||||
teeth_count = math.floor(path_wire_length / params.teeth_spacing)
|
||||
t0 = path.tangentAt(0)
|
||||
z = params.height - params.tolerance + params.teeth_height / 2
|
||||
|
||||
@@ -53,3 +52,47 @@ def rail_teeth(params: Params, path: cq.Wire):
|
||||
)
|
||||
|
||||
return workplane.combine()
|
||||
|
||||
|
||||
def compliant_teeth(params: Params, length: float):
|
||||
teeth_count = math.floor(length / params.teeth_spacing)
|
||||
actual_spacing = length / teeth_count
|
||||
z = params.height - params.tolerance
|
||||
solid_width = u.ldu(1)
|
||||
nozzle_diameter = 0.4
|
||||
layer_height = u.ldu(0.5)
|
||||
layer_count = math.floor(params.teeth_height / layer_height)
|
||||
|
||||
workplane = (
|
||||
cq.Workplane("XY")
|
||||
.pushPoints(
|
||||
[
|
||||
(0, length * ((i - 0.5) / teeth_count), z + params.teeth_height / 2)
|
||||
for i in range(1, teeth_count + 1)
|
||||
]
|
||||
)
|
||||
.box(params.teeth_outer_width, solid_width, params.teeth_height)
|
||||
)
|
||||
|
||||
side_length = math.sqrt(
|
||||
(actual_spacing - solid_width * 1.8) ** 2 + params.teeth_outer_width**2
|
||||
)
|
||||
angle = math.atan2(params.teeth_outer_width, actual_spacing - solid_width * 1.8)
|
||||
direction = cq.Vector(math.sin(angle), math.cos(angle), 0)
|
||||
direction_b = cq.Vector(math.sin(angle), -math.cos(angle), 0)
|
||||
|
||||
for i in range(1, teeth_count):
|
||||
for j in range(layer_count):
|
||||
workplane.add(
|
||||
cq.Workplane(
|
||||
cq.Plane(
|
||||
cq.Vector(
|
||||
0, length * i / teeth_count, z + (j + 0.5) * layer_height
|
||||
),
|
||||
direction if j % 2 == 0 else direction_b,
|
||||
cq.Vector(0, 0, 1),
|
||||
)
|
||||
).box(side_length, nozzle_diameter, layer_height)
|
||||
)
|
||||
|
||||
return workplane.combine()
|
||||
|
||||
+187
@@ -1,4 +1,5 @@
|
||||
from params import Params
|
||||
import math
|
||||
import units as u
|
||||
|
||||
presets = [
|
||||
@@ -134,6 +135,192 @@ presets = [
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid/S25",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(25)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid/R28/C45",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=True,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(28),
|
||||
to=(
|
||||
u.studs(math.sin(math.radians(45)) * 28),
|
||||
u.studs((1 - math.cos(math.radians(45))) * 28),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/C7",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(1), u.studs(7)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/C7_support",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(1), u.studs(7)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/C15",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(5), u.studs(15)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/C15_support",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(5), u.studs(15)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S4",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(4)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S4_support",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(4)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S5",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S5_support",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(5)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S10",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S10_support",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(10)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S25",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(25)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/S25_support",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(25),
|
||||
to=(u.studs(0), u.studs(25)),
|
||||
),
|
||||
),
|
||||
(
|
||||
"solid_support/R28/C45",
|
||||
Params(
|
||||
style=None,
|
||||
shell=False,
|
||||
hollow_studs=False,
|
||||
standoff_flush_cut=False,
|
||||
standoff_uses_pins=True,
|
||||
radius=u.studs(28),
|
||||
to=(
|
||||
u.studs(math.sin(math.radians(45)) * 28),
|
||||
u.studs((1 - math.cos(math.radians(45))) * 28),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
"transrapid/C7",
|
||||
Params(
|
||||
|
||||
Reference in New Issue
Block a user