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

Фланец DN50: скрипт CadQuery (model.py)

Автор: User 254f7fd2

Построено нейросетью по описанию: «Плоский фланец DN50: наружный диаметр 140 мм, толщина 16 мм, центральное отверстие 57 мм, четыре отверстия 18 мм на окружности диаметром 110 мм». Здесь все файлы модели: STEP, STL, GLB, архив, скрипт CadQuery и картинки. Сделать свою деталь: aisearch.ru/aimedia/3d-model

Фланец DN50 - model.py · 1.5 KB · text/x-pythonСделать своёОткрыть в JupyterСкачать
import cadquery as cq
import cadkit as ck

# Parameters for DN50 Flat Flange (Standard-like)
OD = 140.0            # Outer diameter (mm)
THICKNESS = 16.0      # Flange thickness (mm)
BORE_D = 57.0         # Central bore diameter (mm)
BOLT_CIRCLE_D = 110.0 # Bolt circle diameter (mm)
BOLT_HOLE_D = 18.0    # Diameter of bolt holes (mm)
BOLT_COUNT = 4        # Number of bolt holes

# Create the flange using cadkit.flange for precision and standard geometry
# ck.flange(od, bore, thickness, bolt_circle, bolts, bolt_d, hub_d=0, hub_h=0)
flange_body = ck.flange(
    od=OD, 
    bore=BORE_D, 
    thickness=THICKNESS, 
    bolt_circle=BOLT_CIRCLE_D, 
    bolts=BOLT_COUNT, 
    bolt_d=BOLT_HOLE_D
)

# Refine the geometry: add a small chamfer to the outer edge and bore for manufacturability
flange_body = (
    flange_body
    .edges(">Z").chamfer(1.0)
    .edges("<Z").chamfer(1.0)
)

# Create assembly
assy = cq.Assembly()
assy.add(flange_body, name="flange_dn50", color=cq.Color(0.7, 0.7, 0.75))

# Add representative bolts (M16)
# We must provide a UNIQUE name for each part in a CadQuery Assembly
bolt_pos = ck.bolt_pattern(BOLT_CIRCLE_D / 2, BOLT_COUNT)
for i, pos in enumerate(bolt_pos):
    # Use M16 socket screw as a representative fastener
    b = ck.socket_screw(16, 25) 
    # Position the bolt: translate to hole, then move it so head is on top
    b_loc = cq.Location((pos[0], pos[1], THICKNESS))
    # Use f-string to ensure unique name: "m16_bolt_0", "m16_bolt_1", etc.
    assy.add(b, name=f"m16_bolt_{i}", color=cq.Color(0.4, 0.4, 0.4), loc=b_loc)

result = assy

Похожее