Это обновлённый AiSearch.Что-то работает не так? Расскажите или вернитесь на прежнюю версиюСообщитьПрежняя версия✕

Корпус для платы 70×50 мм: скрипт CadQuery (model.py)

Автор: User 254f7fd2

Построено нейросетью по описанию: «Корпус-коробка без крышки для платы 70×50 мм: внешние размеры 80×60×30 мм, толщина стенок и дна 2 мм, четыре стойки под винты M3 в углах, круглое отверстие 12 мм в торцевой стенке под разъём». Здесь все файлы модели: STEP, STL, GLB, архив, скрипт CadQuery и картинки. Сделать свою деталь: aisearch.ru/aimedia/3d-model

Корпус для платы 70×50 мм - model.py · 2.8 KB · text/x-pythonСделать своёОткрыть в JupyterСкачать
import cadquery as cq
import cadkit as ck

# --- Parameters ---
PCB_L, PCB_W = 70.0, 50.0        # PCB dimensions
OUT_L, OUT_W, OUT_H = 80.0, 60.0, 30.0  # Outer dimensions
WALL_T = 2.0                    # Wall and bottom thickness
STANDEE_H = 4.0                  # Height of PCB standoffs above bottom
STANDEE_D = 6.0                  # Diameter of the standoff boss
SCREW_D = 3.0                   # M3 screw diameter
CONNECTOR_D = 12.0              # Diameter of the connector hole
CONNECTOR_X = 0.0               # X position of connector (centered)
CONNECTOR_Y = OUT_W / 2        # Y position (on the end wall)

# Calculate inner dimensions
IN_L = OUT_L - 2 * WALL_T
IN_W = OUT_W - 2 * WALL_T
IN_H = OUT_H - WALL_T

# 1. Main Housing Body
# Create the outer box and shell it to create the walls and bottom
housing = (
    cq.Workplane("XY")
    .box(OUT_L, OUT_W, OUT_H, centered=(True, True, False))
    .edges("|Z").fillet(3) # Slight rounding of outer vertical edges
)

# Create the inner void to subtract (shelling)
inner_void = (
    cq.Workplane("XY")
    .workplane(offset=WALL_T)
    .box(IN_L, IN_W, IN_H + 10, centered=(True, True, False)) # +10 to ensure it cuts through the top
)
housing = housing.cut(inner_void)

# 2. Standoffs for PCB
# Position for the 4 corner standoffs
standoff_pts = [
    (-PCB_L / 2, -PCB_W / 2),
    (PCB_L / 2, -PCB_W / 2),
    (-PCB_L / 2, PCB_W / 2),
    (PCB_L / 2, PCB_W / 2),
]

# Build standoffs as cylinders with holes
standoffs = cq.Workplane("XY").workplane(offset=WALL_T)
for pt in standoff_pts:
    # Create a boss and a hole for M3
    boss = (
        cq.Workplane("XY")
        .workplane(offset=WALL_T)
        .center(*pt)
        .circle(STANDEE_D / 2)
        .extrude(STANDEE_H)
        .faces(">Z").workplane()
        .hole(ck.clearance(SCREW_D)) # Use cadkit for M3 clearance
    )
    housing = housing.union(boss)

# 3. Connector Hole
# Create a cylinder to cut the hole in the end wall
# The wall is at Y = OUT_W / 2. We place the cylinder centered on the wall.
connector_cut = (
    cq.Workplane("XZ")
    .center(CONNECTOR_X, OUT_H / 2) # Center vertically in the wall
    .circle(CONNECTOR_D / 2)
    .extrude(OUT_W, both=True) # Cut through the wall
)
# Adjust vertical position to be centered relative to the bottom
# The box is from z=0 to z=OUT_H. Center of wall is OUT_H/2.
# Let's refine the connector position to be slightly above the floor.
connector_cut = (
    cq.Workplane("XZ")
    .center(CONNECTOR_X, 15.0) # 15mm from bottom
    .circle(CONNECTOR_D / 2)
    .extrude(OUT_W, both=True)
)
housing = housing.cut(connector_cut)

# Final touches: Fillets on the inside bottom edges
housing = housing.edges("<Z").fillet(1)

# Assembly
assy = cq.Assembly()
assy.add(housing, name="enclosure", color=cq.Color(0.2, 0.2, 0.2))

result = assy

Похожее