60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
This script is designed to create tslot extrusion with build123d.
|
|
"""
|
|
from typing import Optional, Tuple
|
|
from pydantic import BaseModel
|
|
from build123d import *
|
|
from ocp_vscode import *
|
|
|
|
from wetrocks import config as conf
|
|
|
|
config = conf.WetRocksConfig()
|
|
|
|
|
|
class TslotConfig(BaseModel):
|
|
tslot_length: float = config.tslot_length
|
|
tslot_width: float = config.tslot_width
|
|
tslot_height: float = config.tslot_height
|
|
tslot_color: tuple = config.tslot_color
|
|
tslot_alpha: float = config.tslot_alpha
|
|
|
|
|
|
def create_tslot(
|
|
tslot_length: float,
|
|
tslot_width: float,
|
|
tslot_height: float,
|
|
tslot_color: tuple,
|
|
tslot_alpha: float,
|
|
) -> "BuildPart":
|
|
with BuildPart() as part:
|
|
with BuildSketch() as profile:
|
|
# Tslot Outline
|
|
with Locations((0, 0)):
|
|
RectangleRounded(
|
|
tslot_width,
|
|
tslot_height,
|
|
0.5,
|
|
align=(Align.MIN, Align.MIN),
|
|
mode=Mode.ADD,
|
|
)
|
|
|
|
extrude(amount=tslot_length)
|
|
|
|
part.color = tslot_color
|
|
return part
|
|
|
|
|
|
def main():
|
|
tslot_config = TslotConfig()
|
|
tslot = create_tslot(**tslot_config.model_dump())
|
|
show_object(
|
|
tslot,
|
|
name="Tslot",
|
|
black_edges=True,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|