Cosplay/nhf/touhou/houjuu_nue/trident.py

56 lines
2.0 KiB
Python
Raw Normal View History

2024-06-25 06:11:48 -07:00
import math
import cadquery as Cq
from nhf import Material, Role
2024-07-04 00:42:14 -07:00
from nhf.parts.handle import Handle
2024-06-25 06:11:48 -07:00
def trident_assembly(
handle: Handle,
2024-07-02 19:59:09 -07:00
handle_segment_length: float = 24*25.4,
terminal_height=100):
2024-06-25 06:11:48 -07:00
def segment():
return handle.segment(handle_segment_length)
2024-07-02 19:59:09 -07:00
terminal = (
handle
.one_side_connector(height=terminal_height)
.faces(">Z")
.hole(15, terminal_height + handle.insertion_length - 10)
)
mat_c = Material.PLASTIC_PLA
mat_i = Material.RESIN_TOUGH_1500
2024-06-25 06:11:48 -07:00
mat_s = Material.ACRYLIC_BLACK
role_i = Role.CONNECTION
role_c = Role.CONNECTION
role_s = Role.STRUCTURE
2024-06-25 06:11:48 -07:00
assembly = (
Cq.Assembly()
.addS(handle.insertion(), name="i0",
material=mat_i, role=role_i)
2024-06-25 06:11:48 -07:00
.constrain("i0", "Fixed")
.addS(segment(), name="s1",
material=mat_s, role=role_s)
2024-06-26 08:28:25 -07:00
.constrain("i0?rim", "s1?mate1", "Plane", param=0)
.addS(handle.insertion(), name="i1",
material=mat_i, role=role_i)
.addS(handle.connector(), name="c1",
material=mat_c, role=role_c)
.addS(handle.insertion(), name="i2",
material=mat_i, role=role_i)
2024-06-26 08:28:25 -07:00
.constrain("s1?mate2", "i1?rim", "Plane", param=0)
2024-06-25 06:11:48 -07:00
.constrain("i1?mate", "c1?mate1", "Plane")
.constrain("i2?mate", "c1?mate2", "Plane")
.addS(segment(), name="s2",
material=mat_s, role=role_s)
2024-06-26 08:28:25 -07:00
.constrain("i2?rim", "s2?mate1", "Plane", param=0)
.addS(handle.insertion(), name="i3",
material=mat_i, role=role_i)
2024-06-26 08:28:25 -07:00
.constrain("s2?mate2", "i3?rim", "Plane", param=0)
.addS(handle.one_side_connector(), name="head",
material=mat_c, role=role_c)
2024-06-26 06:42:50 -07:00
.constrain("i3?mate", "head?mate", "Plane")
.addS(terminal, name="terminal",
material=mat_c, role=role_c)
2024-07-02 19:59:09 -07:00
.constrain("i0?mate", "terminal?mate", "Plane")
2024-06-25 06:11:48 -07:00
)
return assembly.solve()