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

Крышка корпуса 80×60 мм: скрипт CadQuery (model.py)

Автор: User 254f7fd2

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

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

# Parameters
WIDTH = 80.0         # Total width (X)
DEPTH = 60.0         # Total depth (Y)
THICKNESS = 3.0      # Main plate thickness
RIM_HEIGHT = 4.0     # Height of the mating rim
RIM_THICKNESS = 2.0  # Thickness of the rim wall
RIM_OFFSET = 2.0     # Offset of the rim from the outer edge
HOLE_D = 3.2         # Diameter of mounting holes
HOLE_MARGIN = 6.0    # Distance of hole center from edges

# 1. Main Plate
# Create the base plate centered on XY plane, bottom at z=0
plate = (
    cq.Workplane("XY")
    .box(WIDTH, DEPTH, THICKNESS, centered=(True, True, False))
)

# 2. Mating Rim (Bortik)
# The rim is located on the bottom face (z=0)
# The outer dimensions of the rim are (WIDTH - 2*RIM_OFFSET) x (DEPTH - 2*RIM_OFFSET)
# The inner dimensions are (Outer - 2*RIM_THICKNESS)
rim_outer_w = WIDTH - 2 * RIM_OFFSET
rim_outer_d = DEPTH - 2 * RIM_OFFSET
rim_inner_w = rim_outer_w - 2 * RIM_THICKNESS
rim_inner_d = rim_outer_d - 2 * RIM_THICKNESS

# We build the rim by creating a box and cutting a smaller box from it, 
# then translating it to be below the plate (since the plate starts at z=0)
rim = (
    cq.Workplane("XY")
    .box(rim_outer_w, rim_outer_d, RIM_HEIGHT, centered=(True, True, False))
    .cut(
        cq.Workplane("XY")
        .box(rim_inner_w, rim_inner_d, RIM_HEIGHT + 1, centered=(True, True, False))
    )
    .translate((0, 0, -RIM_HEIGHT))
)

# 3. Mounting Holes
# Calculate hole positions based on the margin from the edges
# Since the plate is centered, the edges are at +/- WIDTH/2 and +/- DEPTH/2
hx = (WIDTH / 2) - HOLE_MARGIN
hy = (DEPTH / 2) - HOLE_MARGIN
hole_points = [
    (hx, hy), (-hx, hy), (hx, -hy), (-hx, -hy)
]

# Combine plate and rim, then cut holes through the whole assembly
cover = plate.union(rim)
cover = (
    cover.faces(">Z").workplane()
    .pushPoints(hole_points)
    .hole(HOLE_D)
)

# Final touches: Fillets on the top edges for a professional look
cover = cover.edges(">Z").fillet(1.0)

# Assembly
assy = cq.Assembly()
assy.add(cover, name="cover_plate", color=cq.Color(0.8, 0.8, 0.8))

result = assy

Похожее