first commit

This commit is contained in:
Rafał Paluch 2025-11-26 22:33:11 +01:00
commit 2257d7d3ad
9 changed files with 76 additions and 0 deletions

0
README.md Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

27
rigid.py Normal file
View File

@ -0,0 +1,27 @@
import copy
from build123d import *
from bd_warehouse.flange import WeldNeckFlange
from bd_warehouse.pipe import PipeSection
from ocp_vscode import *
flange_inlet = WeldNeckFlange(nps="10", flange_class=300)
flange_outlet = copy.copy(flange_inlet)
with BuildPart() as pipe_builder:
# Create the pipe
with BuildLine():
path = TangentArc((0, 0, 0), (2 * FT, 0, 1 * FT), tangent=(1, 0, 0))
with BuildSketch(Plane(origin=path @ 0, z_dir=path % 0)):
PipeSection("10", material="stainless", identifier="40S")
sweep()
# Add the joints
RigidJoint(label="inlet", joint_location=-path.location_at(0))
RigidJoint(label="outlet", joint_location=path.location_at(1))
# # Place the flanges at the ends of the pipe
# pipe_builder.part.joints["inlet"].connect_to(flange_inlet.joints["pipe"])
# pipe_builder.part.joints["outlet"].connect_to(flange_outlet.joints["pipe"])
# # show(pipe_builder, flange_inlet, flange_outlet, render_joints=True)
show(pipe_builder, render_joints=True)

49
symulacja.py Normal file
View File

@ -0,0 +1,49 @@
from build123d import *
from ocp_vscode import show
# 1. Importujemy plik STEP
# (Ponieważ nie mam Twojego pliku, symuluję go tutaj jako 'imported_motor')
# imported_motor = import_step("motor_2207.step")
# --- SYMULACJA IMPORTU (Tylko dla przykładu) ---
with BuildPart() as m:
Cylinder(14, 15) # Dzwonek
with Locations((0,0,-2)):
Cylinder(4, 5) # Ośka wystająca w dół (dziwny silnik, ale niech będzie)
# Załóżmy, że ten silnik jest przesunięty w kosmos w pliku STEP:
imported_motor = m.part.moved(Location((100, 200, 50)))
# -----------------------------------------------
# 2. Szukamy miejsca na Jointa (To jest kluczowe przy STEPach!)
# Nie wiemy gdzie on jest (100, 200...), więc szukamy geometrycznie.
# Np. szukamy największej płaskiej ściany na samym spodzie silnika (podstawa)
# Axis.Z ujemne -> szukamy na dole
base_face = imported_motor.faces().sort_by(Axis.Z)[0]
# A może szukamy otworu na śrubę?
# Szukamy krawędzi (edges) będących okręgami, o promieniu 2mm (M4)
# screw_hole = imported_motor.edges().filter_by(GeomType.CIRCLE).filter_by(lambda e: e.radius == 2).first()
# 3. Naklejamy Jointa na znalezioną ścianę
# WAŻNE: Musimy użyć 'to_part', bo modyfikujemy istniejący obiekt, a nie builder.
imported_motor.joints["mount"] = RigidJoint(
label="mount",
to_part=imported_motor,
joint_location=Location(base_face.center()) # Centrum znalezionej ściany
)
# --- TERAZ MOŻEMY GO UŻYĆ ---
# Tworzymy ramię drona
with BuildPart() as arm_builder:
Box(100, 30, 4)
RigidJoint("motor_pad", joint_location=Location((20, 0, 0)))
arm = arm_builder.part
# Łączymy!
# Silnik (który był w kosmosie: 100, 200, 50) przyleci idealnie na ramię.
imported_motor.joints["mount"].connect_to(arm.joints["motor_pad"])
show(arm, imported_motor, render_joints=True)