Compare commits
No commits in common. "8d3459dddbc0a6b26e32d776ea23f07312f1bc01" and "be5dffa5c901f3d3ac21a62b67d77522c1aef9fd" have entirely different histories.
8d3459dddb
...
be5dffa5c9
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,9 +0,0 @@
|
||||
bin
|
||||
include
|
||||
lib64
|
||||
share
|
||||
lib
|
||||
*.step
|
||||
*.stl
|
||||
*.cfg
|
||||
build123d_examples
|
||||
@ -1,17 +0,0 @@
|
||||
from build123d import *
|
||||
from ocp_vscode import *
|
||||
from bd_animation import AnimationGroup, clone, normalize_track
|
||||
|
||||
import copy
|
||||
# %%
|
||||
with BuildPart() as idb_holder:
|
||||
Box(24,46,8)
|
||||
with Locations((0,0,1)):
|
||||
with GridLocations(7,7,3,6):
|
||||
Cylinder(2.3,6,mode=Mode.SUBTRACT)
|
||||
fillet(idb_holder.edges().filter_by(GeomType.CIRCLE), radius=1)
|
||||
fillet(idb_holder.edges().filter_by(Axis.Z), radius=5)
|
||||
fillet(idb_holder.edges().group_by(Axis.Z)[-1].filter_by(GeomType.LINE)[0], radius=1.5)
|
||||
show(idb_holder)
|
||||
# %%
|
||||
export_step(idb_holder.part, "idb_holder.step")
|
||||
358
drops.py
358
drops.py
@ -45,6 +45,7 @@ with BuildPart() as pezdrops:
|
||||
loft(mode=Mode.SUBTRACT)
|
||||
fillet(pezdrops.faces().sort_by(Axis.Z)[0].edges(), radius=1)
|
||||
|
||||
|
||||
show(pezdrops)
|
||||
# %%
|
||||
with BuildPart() as mold:
|
||||
@ -89,3 +90,360 @@ show(mold_for_mold)
|
||||
# %%
|
||||
#export_step(pezmold.part, "pezmold.step")
|
||||
# %%
|
||||
|
||||
nHoles = 10
|
||||
vol_ml = 1.0 # millilitiers = 1/1000 * 10cm*10cm*10cm = 100mm*100mm*100mm/1000 = 1000mm³
|
||||
vol = vol_ml * 1000
|
||||
r = 4 # millimeters
|
||||
ri = 2
|
||||
rrod=1
|
||||
rodlen=100
|
||||
tol = 0.05
|
||||
A = 3.14*r*r
|
||||
t = 2*vol/A # liter/meter
|
||||
wt = 1
|
||||
l, w, h = (r*2+wt)*(nHoles+0.5)+8, t+8, (r+wt)*2
|
||||
|
||||
with BuildPart() as pumpcylindercutout:
|
||||
with BuildSketch(Plane.XZ) as holes_sk:
|
||||
Circle(r)
|
||||
|
||||
extrude(amount=t)
|
||||
with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Y)[0]) as rodhole_sk:
|
||||
Circle(rrod+tol)
|
||||
extrude(amount=10)
|
||||
chamfer(pumpcylindercutout.edges().sort_by(Axis.Y)[3],2)
|
||||
with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Y)[0]) as rodhole_sk:
|
||||
Circle(r)
|
||||
Circle(rrod+2, mode=Mode.SUBTRACT)
|
||||
extrude(amount=10)
|
||||
|
||||
|
||||
show(pumpcylindercutout,pumpcylindercutout.edges().sort_by(Axis.Y)[2])
|
||||
#%%
|
||||
|
||||
with BuildPart() as pumpcylinderblock:
|
||||
Box(l,w,h)
|
||||
f = pumpcylinderblock.faces()[5].offset(-t)
|
||||
#with GridLocations()
|
||||
with Locations((0,t/2+4)):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(pumpcylindercutout,mode=Mode.SUBTRACT)
|
||||
#chamfer(pumpcylinderblock.edges().group_by(Axis.Z)[-1].filter_by(GeomType.CIRCLE), 0.4)
|
||||
RigidJoint("slide", joint_location=Location(Plane.XY))
|
||||
with BuildSketch(pumpcylinderblock.faces().sort_by(Axis.Z)[-1].translate((0,5,0))):
|
||||
RectangleRounded(l-10,r*2+0.1, 2)
|
||||
extrude(amount=-r,mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.XY.offset(h/2)) as holes:
|
||||
with Locations((0,5,0)):
|
||||
with GridLocations(l-6,w-6-10,2,2):
|
||||
Circle(1.5)
|
||||
extrude(amount=-h,mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.XZ.offset(25)) as holes:
|
||||
with GridLocations(l-6,h-5,2,1):
|
||||
Circle(1.5)
|
||||
extrude(amount=-h,mode=Mode.SUBTRACT)
|
||||
|
||||
show(pumpcylinderblock)
|
||||
|
||||
|
||||
|
||||
#%%
|
||||
with BuildPart() as oese:
|
||||
c=Cylinder(3,2,rotation=(0,90,0))
|
||||
fillet(c.edges().filter_by(GeomType.CIRCLE), 0.9)
|
||||
Cylinder(1.5,2,rotation=(0,90,0), mode=Mode.SUBTRACT)
|
||||
show(oese)
|
||||
|
||||
|
||||
#%%
|
||||
with BuildPart() as pumpvalverod:
|
||||
rodlen=60
|
||||
#Cylinder(3,4)
|
||||
#with Locations((0,0,rodlen/2-10)):
|
||||
# Cylinder(rrod,rodlen)
|
||||
with BuildSketch(Plane.XY) as sk:
|
||||
with BuildLine() as outline:
|
||||
d=2
|
||||
hn=1
|
||||
l1=CenterArc((0,-rrod),rrod,270,90)
|
||||
l2=Line(l1@1,(rrod,hn))
|
||||
l3=Line(l2@1,(rrod+d,hn+d))
|
||||
l4=Line(l3@1,(rrod,hn+2*d))
|
||||
l5=Line(l4@1,(rrod,rodlen))
|
||||
l6=CenterArc((0,rodlen),rrod,0,90)
|
||||
l7=Line(l6@1,l1@0)
|
||||
make_face()
|
||||
revolve(axis=Axis.Y)
|
||||
fillet(pumpvalverod.edges().sort_by(Axis.Y)[5],0.5)
|
||||
with Locations((0,rodlen-3,0),(0,rodlen-9,0)):
|
||||
with Locations((-rrod,0,0),(rrod,0,0)):
|
||||
Box(rrod,3,4, mode=Mode.SUBTRACT)
|
||||
|
||||
show(pumpvalverod)
|
||||
|
||||
|
||||
# %%
|
||||
with BuildPart() as pumpcylinder:
|
||||
rodlen=50
|
||||
clen=8
|
||||
elen=10
|
||||
slen= 20
|
||||
dy=-13
|
||||
with BuildSketch(Plane.XZ.offset(dy)) as cl_sk:
|
||||
Circle(r)
|
||||
Circle(ri,mode=Mode.SUBTRACT)
|
||||
extrude(amount=clen)
|
||||
chamfer(pumpcylinder.edges().group_by(Axis.Y)[0][1],1)
|
||||
with BuildSketch(pumpcylinder.faces().sort_by(Axis.Y)[-1]) as rods_sk:
|
||||
with PolarLocations(r-(r-ri)/2,3,90):
|
||||
Circle((r-ri)/2)
|
||||
extrude(amount=slen)
|
||||
with BuildSketch(Plane.XZ.offset(dy-slen-clen)) as cl_sk:
|
||||
Circle(r)
|
||||
Circle(rrod+0.05, mode=Mode.SUBTRACT)
|
||||
extrude(amount=elen)
|
||||
with BuildSketch(pumpcylinder.faces().sort_by(Axis.Y)[-1]) as rods_sk:
|
||||
with PolarLocations(r-(r-ri)/2,2,0):
|
||||
Rectangle((r-ri)/2,r)
|
||||
#Circle((r-ri)/2)
|
||||
extrude(amount=rodlen-clen-slen-elen)
|
||||
with Locations((0,rodlen-1.5,r-0.25),(0,rodlen-1.5,-r+0.25)):
|
||||
Box(15,3,5,mode=Mode.SUBTRACT)
|
||||
|
||||
show(pumpcylinder,pumpvalverod)
|
||||
|
||||
|
||||
#%%
|
||||
# MACHINE ASSEMBLY
|
||||
openstate = False
|
||||
pumped = True
|
||||
trlen =2
|
||||
pumplen=5
|
||||
loc_rods = (0,-18-openstate*trlen+pumped*pumplen,0)
|
||||
loc_cyls = (0,-20-openstate*trlen+pumped*pumplen,0)
|
||||
|
||||
with BuildPart() as pumpcylinderrods:
|
||||
with Locations(loc_rods):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(copy.copy(pumpvalverod))
|
||||
|
||||
with BuildPart() as pumpcylinders:
|
||||
with Locations(loc_cyls):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(copy.copy(pumpcylinder),rotation=(0,0,0),)
|
||||
LinearJoint("cylinders", axis=Axis.Z, linear_range=(-t, t))
|
||||
pumpcylinderblock.part.joints["slide"].connect_to(pumpcylinders.joints["cylinders"])
|
||||
|
||||
|
||||
show(pumpcylinderblock,pumpcylinderrods,pumpcylinders,render_joints=True)#, pumpcylindercutout)# %%
|
||||
#%%
|
||||
with BuildPart() as nozzle:
|
||||
#with BuildLine(Plane.XZ) as pipe:
|
||||
# RadiusArc((0,0),(-10,-10,), -10)
|
||||
dn=10
|
||||
with BuildSketch(Plane.XZ) as profile:
|
||||
Circle(rrod+3)
|
||||
with BuildSketch(Plane.XY.offset(-dn).rotated((-45,0,0))) as endprofile:
|
||||
with Locations((0,-dn)):
|
||||
Circle(rrod+1)
|
||||
#sweep(sections=[profile.sketch, endprofile.sketch], path=pipe)
|
||||
loft()
|
||||
#offset(amount=3,openings=[nozzle.faces().sort_by(Axis.X)[-1], nozzle.faces().sort_by(Axis.Z)[0]],side=Side.LEFT,)
|
||||
e= nozzle.edges().sort_by(Axis.Z)[0]
|
||||
fillet(e, radius=0.7)
|
||||
with BuildSketch(Plane.XZ) as profile:
|
||||
Circle(rrod)
|
||||
with BuildSketch(Plane.XY.offset(-dn).rotated((-45,0,0))) as endprofile:
|
||||
with Locations((0,-dn)):
|
||||
Circle(rrod)
|
||||
#sweep(sections=[profile.sketch, endprofile.sketch], path=pipe)
|
||||
loft(mode=Mode.SUBTRACT)
|
||||
|
||||
show(e,nozzle)
|
||||
# %%
|
||||
with BuildPart() as nozzleplate:
|
||||
tp = 2
|
||||
with Locations((0,-w/2-tp/2,0)):
|
||||
Box(l,tp,h)
|
||||
with Locations((0,-w/2-tp,0)):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(copy.copy(nozzle.part),rotation=(0,0,0))
|
||||
with Locations((0,-w/2-tp/2,0)):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
Cylinder(rrod,tp,mode=Mode.SUBTRACT,rotation=(90,0,0))
|
||||
|
||||
show(pumpcylinderblock, nozzleplate)
|
||||
|
||||
#%%
|
||||
with BuildPart() as rodcollector:
|
||||
loc_col=list(loc_rods)
|
||||
dyc = rodlen-14-openstate*trlen +pumped*pumplen#+ loc_col[1]
|
||||
loc_col[1] = dyc
|
||||
loc_col[2]=-2
|
||||
with Locations(tuple(loc_col)):
|
||||
Box(l,10,2)
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
with Locations((-rrod,dyc-3,0), (rrod,dyc-3,0),(-rrod,dyc+3,0), (rrod,dyc+3,0)):
|
||||
Box(rrod,3,rrod*2)
|
||||
with Locations((-rrod*1.5,dyc,0), (rrod*1.5,dyc,0)):
|
||||
Box(rrod,10,rrod*2)
|
||||
with Locations((-rrod*4,dyc-2.5,-2), (rrod*4,dyc-2.5,-2)):
|
||||
Box(4*rrod,5,2,mode=Mode.SUBTRACT)
|
||||
#fillet(rodcollector.edges(Select.LAST).group_by(Axis.Z)[0].filter_by(lambda a: a.length==10), radius=1)
|
||||
|
||||
show(rodcollector)
|
||||
#%%
|
||||
with BuildPart() as cylindercollector:
|
||||
dyc = rodlen-21.5 +pumped*pumplen
|
||||
with Locations((0,dyc,1.7),(0,dyc,-1.7)):
|
||||
Box(l,3-0.1,0.77)
|
||||
with Locations((0,dyc,3),(0,dyc,-3)):
|
||||
Box(l+20,10, 2)
|
||||
with Locations((0,dyc,0),(0,dyc,0)):
|
||||
with GridLocations(l+10,0,2,1,):
|
||||
Cylinder(3.1/2,20,mode=Mode.SUBTRACT)
|
||||
|
||||
show(rodcollector,cylindercollector,nozzleplate,pumpcylinderblock,pumpcylinderrods,pumpcylinders)#, pumpcylindercutout)
|
||||
# %%
|
||||
show(rodcollector.edges(Select.LAST).group_by(Axis.Z)[0].filter_by(lambda a: a.length==10))
|
||||
# %%
|
||||
with BuildPart() as hopper:
|
||||
with BuildSketch(Plane.XY.offset(h/2)) as down_sk:
|
||||
with Locations((0,5)):
|
||||
Rectangle(l-8,15)
|
||||
with BuildSketch(Plane.XY.offset(160).rotated((-45,0,0))) as up_sk:
|
||||
with Locations((0,50)):
|
||||
Rectangle(230,200)
|
||||
loft()
|
||||
offset(amount=-1, openings=[hopper.faces().sort_by(Axis.Z)[0],\
|
||||
hopper.faces().sort_by(Axis.Z)[-1]])
|
||||
with BuildSketch(Plane.XY.offset(h/2)) as downs_sk:
|
||||
Rectangle(l,w)
|
||||
with Locations((0,5)):
|
||||
Rectangle(l-10,20, mode=Mode.SUBTRACT)
|
||||
extrude(amount=1)
|
||||
with BuildSketch(Plane.XY.offset(h/2+2)) as holes:
|
||||
with Locations((0,5,0)):
|
||||
with GridLocations(l-6,w-6-10,2,2):
|
||||
Circle(1.5)
|
||||
extrude(amount=-h,mode=Mode.SUBTRACT)
|
||||
|
||||
#show(hopper)
|
||||
show(rodcollector,cylindercollector,nozzleplate,pumpcylinderblock,pumpcylinderrods,pumpcylinders,hopper,render_joints=True)#, pumpcylindercutout)# %%
|
||||
|
||||
# %%
|
||||
|
||||
# %%
|
||||
hopperblock = pumpcylinderblock.part + hopper.part
|
||||
show(hopperblock)
|
||||
# %%
|
||||
with BuildPart() as stand:
|
||||
ws = 120
|
||||
wsx=60
|
||||
with Locations((0,0,-h/2)):
|
||||
Box(wsx,ws,4)
|
||||
Box(wsx-4,ws-4,4,mode=Mode.SUBTRACT)
|
||||
Box(wsx,4,4)
|
||||
Box(4,ws,4)
|
||||
with Locations((0,0,-1)):
|
||||
Box(l+2,w+2,h+2)
|
||||
|
||||
Box(l,w,h, mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.XY.offset(-(h+2)/2+3)):
|
||||
RectangleRounded(l-3,w-3,3)
|
||||
extrude(amount=-10, mode=Mode.SUBTRACT)
|
||||
|
||||
with BuildPart() as standfoot:
|
||||
hs=50
|
||||
ws=12
|
||||
Box(ws,ws,hs)
|
||||
ds=2
|
||||
with Locations((-ds,-ds,0)):
|
||||
Box(ws-ds,ws-ds,hs,mode=Mode.SUBTRACT)
|
||||
with Locations((0,0,hs/2-2)):
|
||||
Box(ws,4,4,mode=Mode.SUBTRACT)
|
||||
Box(4,ws,4,mode=Mode.SUBTRACT)
|
||||
|
||||
#extrude(amount=4)
|
||||
#offset(amount=-1.9, openings=[stand.faces().sort_by(Axis.Z)[-1]])
|
||||
show(standfoot)
|
||||
# %%
|
||||
#export_step(hopperblock, "machineparts/hopperblock.step")
|
||||
#export_step(stand.part, "machineparts/stand.step")
|
||||
#export_step(standfoot.part, "machineparts/standfoot.step")
|
||||
#export_step(pumpvalverod.part, "machineparts/valverod.step")
|
||||
#export_step(pumpcylinder.part, "machineparts/pumpcylinder.step")
|
||||
# %%
|
||||
with BuildPart() as idb_holder:
|
||||
Box(24,46,8)
|
||||
with Locations((0,0,1)):
|
||||
with GridLocations(7,7,3,6):
|
||||
Cylinder(2.3,6,mode=Mode.SUBTRACT)
|
||||
fillet(idb_holder.edges().filter_by(GeomType.CIRCLE), radius=1)
|
||||
fillet(idb_holder.edges().filter_by(Axis.Z), radius=5)
|
||||
fillet(idb_holder.edges().group_by(Axis.Z)[-1].filter_by(GeomType.LINE)[0], radius=1.5)
|
||||
show(idb_holder)
|
||||
# %%
|
||||
export_step(idb_holder.part, "idb_holder.step")
|
||||
# %%
|
||||
|
||||
def step_profile(stepfile="/home/hbrs/Downloads/tmp/I_slot_5_20x40.stp"):
|
||||
iprofile = import_step(stepfile)
|
||||
iface = iprofile.faces().sort_by(Axis.Z)[0]
|
||||
|
||||
def buildfn(length=50):
|
||||
with BuildPart() as profile:
|
||||
with BuildSketch() as profile_sk:
|
||||
add(iface)
|
||||
extrude(amount=length)
|
||||
return Pos(0,13.3765,0)*Rot(0,0,90)*profile.part
|
||||
|
||||
return buildfn
|
||||
|
||||
iprofile=step_profile()
|
||||
# %%
|
||||
hp = 260
|
||||
w = 240
|
||||
w1 = w+40
|
||||
w2 =hp+20
|
||||
w3 = hp + 40
|
||||
profiles= [ \
|
||||
Pos(0,0,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(w1,0,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(0,w2,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(w1,w2,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(0,w2,0)*Rot(90,90,0)*iprofile(w), \
|
||||
Pos(0,0,0)*Rot(90,90,0)*iprofile(w), \
|
||||
Pos(-40,20,40)*Rot(-90,0,0)*iprofile(hp), \
|
||||
Pos(hp,20,40)*Rot(-90,0,0)*iprofile(hp), \
|
||||
Pos(0,0,w2)*Rot(-90,0,90)*iprofile(w3), \
|
||||
Pos(w2,0,w2)*Rot(-90,0,90)*iprofile(w3), \
|
||||
Pos(w2/2,0,60)*Rot(-90,0,90)*iprofile(w3), \
|
||||
]
|
||||
show(*profiles)#, hopperblock)
|
||||
# %%
|
||||
#ASSEMBLY
|
||||
extruder = Compound(label="Extruder",children=[rodcollector.part,cylindercollector.part,nozzleplate.part,\
|
||||
pumpcylinderblock.part,pumpcylinderrods.part,pumpcylinders.part,hopper.part])
|
||||
extruder=Pos(120,170,168)*Rot(45,0,0)*extruder
|
||||
#extruder.translate((hp/2,0,0))
|
||||
show(*profiles,extruder)#, pumpcylindercutout)# %%
|
||||
|
||||
# %%
|
||||
railpath = "/home/hbrs/Downloads/8381K54_Miniature Ball Bearing Carriage and Guide Rail.STEP"
|
||||
carriagepath = "/home/hbrs/Downloads/6725K531_12 mm Wide x 200 mm Long Rail for Ball Bearing Carriage.STEP"
|
||||
|
||||
rail = import_step(railpath)
|
||||
carriage = import_step(carriagepath)
|
||||
show(carriage)
|
||||
# %%
|
||||
#cmpds = rail.compound()
|
||||
shapes = rail.entities(topo_type=Part)
|
||||
# %# %%
|
||||
|
||||
len(shapes)# %%
|
||||
|
||||
# %%
|
||||
show(shapes[0])
|
||||
# %%
|
||||
|
||||
365
drops_machine.py
365
drops_machine.py
@ -1,365 +0,0 @@
|
||||
from build123d import *
|
||||
from ocp_vscode import *
|
||||
from bd_animation import AnimationGroup, clone, normalize_track
|
||||
|
||||
import copy
|
||||
#%%
|
||||
text = Text("z",
|
||||
font_size=8.0,
|
||||
font_path="/usr/share/fonts/truetype/ebgaramond/EBGaramond12-Bold.ttf",
|
||||
font_style=FontStyle.BOLD,)
|
||||
|
||||
show(text)
|
||||
set_defaults(reset_camera=Camera.KEEP, render_joints=True, helper_scale=8)
|
||||
|
||||
|
||||
nHoles = 10
|
||||
vol_ml = 1.0 # millilitiers = 1/1000 * 10cm*10cm*10cm = 100mm*100mm*100mm/1000 = 1000mm³
|
||||
vol = vol_ml * 1000
|
||||
r = 4 # millimeters
|
||||
ri = 2
|
||||
rrod=1
|
||||
rodlen=100
|
||||
tol = 0.05
|
||||
A = 3.14*r*r
|
||||
t = 2*vol/A # liter/meter
|
||||
wt = 1
|
||||
l, w, h = (r*2+wt)*(nHoles+0.5)+8, t+8, (r+wt)*2
|
||||
|
||||
with BuildPart() as pumpcylindercutout:
|
||||
with BuildSketch(Plane.XZ) as holes_sk:
|
||||
Circle(r)
|
||||
|
||||
extrude(amount=t)
|
||||
with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Y)[0]) as rodhole_sk:
|
||||
Circle(rrod+tol)
|
||||
extrude(amount=10)
|
||||
chamfer(pumpcylindercutout.edges().sort_by(Axis.Y)[3],2)
|
||||
with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Y)[0]) as rodhole_sk:
|
||||
Circle(r)
|
||||
Circle(rrod+2, mode=Mode.SUBTRACT)
|
||||
extrude(amount=10)
|
||||
|
||||
|
||||
show(pumpcylindercutout,pumpcylindercutout.edges().sort_by(Axis.Y)[2])
|
||||
#%%
|
||||
|
||||
with BuildPart() as pumpcylinderblock:
|
||||
Box(l,w,h)
|
||||
f = pumpcylinderblock.faces()[5].offset(-t)
|
||||
#with GridLocations()
|
||||
with Locations((0,t/2+4)):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(pumpcylindercutout,mode=Mode.SUBTRACT)
|
||||
#chamfer(pumpcylinderblock.edges().group_by(Axis.Z)[-1].filter_by(GeomType.CIRCLE), 0.4)
|
||||
RigidJoint("slide", joint_location=Location(Plane.XY))
|
||||
with BuildSketch(pumpcylinderblock.faces().sort_by(Axis.Z)[-1].translate((0,5,0))):
|
||||
RectangleRounded(l-10,r*2+0.1, 2)
|
||||
extrude(amount=-r,mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.XY.offset(h/2)) as holes:
|
||||
with Locations((0,5,0)):
|
||||
with GridLocations(l-6,w-6-10,2,2):
|
||||
Circle(1.5)
|
||||
extrude(amount=-h,mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.XZ.offset(25)) as holes:
|
||||
with GridLocations(l-6,h-5,2,1):
|
||||
Circle(1.5)
|
||||
extrude(amount=-h,mode=Mode.SUBTRACT)
|
||||
|
||||
show(pumpcylinderblock)
|
||||
|
||||
#%%
|
||||
with BuildPart() as pumpvalverod:
|
||||
rodlen=60
|
||||
#Cylinder(3,4)
|
||||
#with Locations((0,0,rodlen/2-10)):
|
||||
# Cylinder(rrod,rodlen)
|
||||
with BuildSketch(Plane.XY) as sk:
|
||||
with BuildLine() as outline:
|
||||
d=2
|
||||
hn=1
|
||||
l1=CenterArc((0,-rrod),rrod,270,90)
|
||||
l2=Line(l1@1,(rrod,hn))
|
||||
l3=Line(l2@1,(rrod+d,hn+d))
|
||||
l4=Line(l3@1,(rrod,hn+2*d))
|
||||
l5=Line(l4@1,(rrod,rodlen))
|
||||
l6=CenterArc((0,rodlen),rrod,0,90)
|
||||
l7=Line(l6@1,l1@0)
|
||||
make_face()
|
||||
revolve(axis=Axis.Y)
|
||||
fillet(pumpvalverod.edges().sort_by(Axis.Y)[5],0.5)
|
||||
with Locations((0,rodlen-3,0),(0,rodlen-9,0)):
|
||||
with Locations((-rrod,0,0),(rrod,0,0)):
|
||||
Box(rrod,3,4, mode=Mode.SUBTRACT)
|
||||
|
||||
show(pumpvalverod)
|
||||
|
||||
|
||||
# %%
|
||||
with BuildPart() as pumpcylinder:
|
||||
rodlen=50
|
||||
clen=8
|
||||
elen=10
|
||||
slen= 20
|
||||
dy=-13
|
||||
with BuildSketch(Plane.XZ.offset(dy)) as cl_sk:
|
||||
Circle(r)
|
||||
Circle(ri,mode=Mode.SUBTRACT)
|
||||
extrude(amount=clen)
|
||||
chamfer(pumpcylinder.edges().group_by(Axis.Y)[0][1],1)
|
||||
with BuildSketch(pumpcylinder.faces().sort_by(Axis.Y)[-1]) as rods_sk:
|
||||
with PolarLocations(r-(r-ri)/2,3,90):
|
||||
Circle((r-ri)/2)
|
||||
extrude(amount=slen)
|
||||
with BuildSketch(Plane.XZ.offset(dy-slen-clen)) as cl_sk:
|
||||
Circle(r)
|
||||
Circle(rrod+0.05, mode=Mode.SUBTRACT)
|
||||
extrude(amount=elen)
|
||||
with BuildSketch(pumpcylinder.faces().sort_by(Axis.Y)[-1]) as rods_sk:
|
||||
with PolarLocations(r-(r-ri)/2,2,0):
|
||||
Rectangle((r-ri)/2,r)
|
||||
#Circle((r-ri)/2)
|
||||
extrude(amount=rodlen-clen-slen-elen)
|
||||
with Locations((0,rodlen-1.5,r-0.25),(0,rodlen-1.5,-r+0.25)):
|
||||
Box(15,3,5,mode=Mode.SUBTRACT)
|
||||
|
||||
show(pumpcylinder,pumpvalverod)
|
||||
|
||||
|
||||
#%%
|
||||
# MACHINE ASSEMBLY
|
||||
openstate = False
|
||||
pumped = True
|
||||
trlen =2
|
||||
pumplen=5
|
||||
loc_rods = (0,-18-openstate*trlen+pumped*pumplen,0)
|
||||
loc_cyls = (0,-20-openstate*trlen+pumped*pumplen,0)
|
||||
|
||||
with BuildPart() as pumpcylinderrods:
|
||||
with Locations(loc_rods):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(copy.copy(pumpvalverod))
|
||||
|
||||
with BuildPart() as pumpcylinders:
|
||||
with Locations(loc_cyls):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(copy.copy(pumpcylinder),rotation=(0,0,0),)
|
||||
LinearJoint("cylinders", axis=Axis.Z, linear_range=(-t, t))
|
||||
pumpcylinderblock.part.joints["slide"].connect_to(pumpcylinders.joints["cylinders"])
|
||||
|
||||
|
||||
show(pumpcylinderblock,pumpcylinderrods,pumpcylinders,render_joints=True)#, pumpcylindercutout)# %%
|
||||
#%%
|
||||
with BuildPart() as nozzle:
|
||||
#with BuildLine(Plane.XZ) as pipe:
|
||||
# RadiusArc((0,0),(-10,-10,), -10)
|
||||
dn=10
|
||||
with BuildSketch(Plane.XZ) as profile:
|
||||
Circle(rrod+3)
|
||||
with BuildSketch(Plane.XY.offset(-dn).rotated((-45,0,0))) as endprofile:
|
||||
with Locations((0,-dn)):
|
||||
Circle(rrod+1)
|
||||
#sweep(sections=[profile.sketch, endprofile.sketch], path=pipe)
|
||||
loft()
|
||||
#offset(amount=3,openings=[nozzle.faces().sort_by(Axis.X)[-1], nozzle.faces().sort_by(Axis.Z)[0]],side=Side.LEFT,)
|
||||
e= nozzle.edges().sort_by(Axis.Z)[0]
|
||||
fillet(e, radius=0.7)
|
||||
with BuildSketch(Plane.XZ) as profile:
|
||||
Circle(rrod)
|
||||
with BuildSketch(Plane.XY.offset(-dn).rotated((-45,0,0))) as endprofile:
|
||||
with Locations((0,-dn)):
|
||||
Circle(rrod)
|
||||
#sweep(sections=[profile.sketch, endprofile.sketch], path=pipe)
|
||||
loft(mode=Mode.SUBTRACT)
|
||||
|
||||
show(e,nozzle)
|
||||
# %%
|
||||
with BuildPart() as nozzleplate:
|
||||
tp = 2
|
||||
with Locations((0,-w/2-tp/2,0)):
|
||||
Box(l,tp,h)
|
||||
with Locations((0,-w/2-tp,0)):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
add(copy.copy(nozzle.part),rotation=(0,0,0))
|
||||
with Locations((0,-w/2-tp/2,0)):
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
Cylinder(rrod,tp,mode=Mode.SUBTRACT,rotation=(90,0,0))
|
||||
|
||||
show(pumpcylinderblock, nozzleplate)
|
||||
|
||||
#%%
|
||||
with BuildPart() as rodcollector:
|
||||
loc_col=list(loc_rods)
|
||||
dyc = rodlen-14-openstate*trlen +pumped*pumplen#+ loc_col[1]
|
||||
loc_col[1] = dyc
|
||||
loc_col[2]=-2
|
||||
with Locations(tuple(loc_col)):
|
||||
Box(l,10,2)
|
||||
with GridLocations(r+wt+r,0,nHoles,1):
|
||||
with Locations((-rrod,dyc-3,0), (rrod,dyc-3,0),(-rrod,dyc+3,0), (rrod,dyc+3,0)):
|
||||
Box(rrod,3,rrod*2)
|
||||
with Locations((-rrod*1.5,dyc,0), (rrod*1.5,dyc,0)):
|
||||
Box(rrod,10,rrod*2)
|
||||
with Locations((-rrod*4,dyc-2.5,-2), (rrod*4,dyc-2.5,-2)):
|
||||
Box(4*rrod,5,2,mode=Mode.SUBTRACT)
|
||||
#fillet(rodcollector.edges(Select.LAST).group_by(Axis.Z)[0].filter_by(lambda a: a.length==10), radius=1)
|
||||
|
||||
show(rodcollector)
|
||||
#%%
|
||||
with BuildPart() as cylindercollector:
|
||||
dyc = rodlen-21.5 +pumped*pumplen
|
||||
with Locations((0,dyc,1.7),(0,dyc,-1.7)):
|
||||
Box(l,3-0.1,0.77)
|
||||
with Locations((0,dyc,3),(0,dyc,-3)):
|
||||
Box(l+20,10, 2)
|
||||
with Locations((0,dyc,0),(0,dyc,0)):
|
||||
with GridLocations(l+10,0,2,1,):
|
||||
Cylinder(3.1/2,20,mode=Mode.SUBTRACT)
|
||||
|
||||
show(rodcollector,cylindercollector,nozzleplate,pumpcylinderblock,pumpcylinderrods,pumpcylinders)#, pumpcylindercutout)
|
||||
# %%
|
||||
show(rodcollector.edges(Select.LAST).group_by(Axis.Z)[0].filter_by(lambda a: a.length==10))
|
||||
# %%
|
||||
with BuildPart() as hopper:
|
||||
with BuildSketch(Plane.XY.offset(h/2)) as down_sk:
|
||||
with Locations((0,5)):
|
||||
Rectangle(l-8,15)
|
||||
with BuildSketch(Plane.XY.offset(160).rotated((-45,0,0))) as up_sk:
|
||||
with Locations((0,50)):
|
||||
Rectangle(230,200)
|
||||
loft()
|
||||
offset(amount=-1, openings=[hopper.faces().sort_by(Axis.Z)[0],\
|
||||
hopper.faces().sort_by(Axis.Z)[-1]])
|
||||
with BuildSketch(Plane.XY.offset(h/2)) as downs_sk:
|
||||
Rectangle(l,w)
|
||||
with Locations((0,5)):
|
||||
Rectangle(l-10,20, mode=Mode.SUBTRACT)
|
||||
extrude(amount=1)
|
||||
with BuildSketch(Plane.XY.offset(h/2+2)) as holes:
|
||||
with Locations((0,5,0)):
|
||||
with GridLocations(l-6,w-6-10,2,2):
|
||||
Circle(1.5)
|
||||
extrude(amount=-h,mode=Mode.SUBTRACT)
|
||||
|
||||
#show(hopper)
|
||||
show(rodcollector,cylindercollector,nozzleplate,pumpcylinderblock,pumpcylinderrods,pumpcylinders,hopper,render_joints=True)#, pumpcylindercutout)# %%
|
||||
|
||||
# %%
|
||||
|
||||
# %%
|
||||
hopperblock = pumpcylinderblock.part + hopper.part
|
||||
show(hopperblock)
|
||||
# %%
|
||||
with BuildPart() as stand:
|
||||
ws = 120
|
||||
wsx=60
|
||||
with Locations((0,0,-h/2)):
|
||||
Box(wsx,ws,4)
|
||||
Box(wsx-4,ws-4,4,mode=Mode.SUBTRACT)
|
||||
Box(wsx,4,4)
|
||||
Box(4,ws,4)
|
||||
with Locations((0,0,-1)):
|
||||
Box(l+2,w+2,h+2)
|
||||
|
||||
Box(l,w,h, mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.XY.offset(-(h+2)/2+3)):
|
||||
RectangleRounded(l-3,w-3,3)
|
||||
extrude(amount=-10, mode=Mode.SUBTRACT)
|
||||
|
||||
with BuildPart() as standfoot:
|
||||
hs=50
|
||||
ws=12
|
||||
Box(ws,ws,hs)
|
||||
ds=2
|
||||
with Locations((-ds,-ds,0)):
|
||||
Box(ws-ds,ws-ds,hs,mode=Mode.SUBTRACT)
|
||||
with Locations((0,0,hs/2-2)):
|
||||
Box(ws,4,4,mode=Mode.SUBTRACT)
|
||||
Box(4,ws,4,mode=Mode.SUBTRACT)
|
||||
|
||||
#extrude(amount=4)
|
||||
#offset(amount=-1.9, openings=[stand.faces().sort_by(Axis.Z)[-1]])
|
||||
show(standfoot)
|
||||
# %%
|
||||
#export_step(hopperblock, "machineparts/hopperblock.step")
|
||||
#export_step(stand.part, "machineparts/stand.step")
|
||||
#export_step(standfoot.part, "machineparts/standfoot.step")
|
||||
#export_step(pumpvalverod.part, "machineparts/valverod.step")
|
||||
#export_step(pumpcylinder.part, "machineparts/pumpcylinder.step")
|
||||
|
||||
# %%
|
||||
|
||||
def step_profile(stepfile="/home/hbrs/Downloads/tmp/I_slot_5_20x40.stp"):
|
||||
iprofile = import_step(stepfile)
|
||||
iface = iprofile.faces().sort_by(Axis.Z)[0]
|
||||
|
||||
def buildfn(length=50):
|
||||
with BuildPart() as profile:
|
||||
with BuildSketch() as profile_sk:
|
||||
add(iface)
|
||||
extrude(amount=length)
|
||||
return Pos(0,13.3765,0)*Rot(0,0,90)*profile.part
|
||||
|
||||
return buildfn
|
||||
|
||||
iprofile=step_profile()
|
||||
# %%
|
||||
hp = 260
|
||||
w = 240
|
||||
w1 = w+40
|
||||
w2 =hp+20
|
||||
w3 = hp + 40
|
||||
profiles= [ \
|
||||
Pos(0,0,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(w1,0,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(0,w2,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(w1,w2,0)*Rot(0,0,90)*iprofile(hp), \
|
||||
Pos(0,w2,0)*Rot(90,90,0)*iprofile(w), \
|
||||
Pos(0,0,0)*Rot(90,90,0)*iprofile(w), \
|
||||
Pos(-40,20,40)*Rot(-90,0,0)*iprofile(hp), \
|
||||
Pos(hp,20,40)*Rot(-90,0,0)*iprofile(hp), \
|
||||
Pos(0,0,w2)*Rot(-90,0,90)*iprofile(w3), \
|
||||
Pos(w2,0,w2)*Rot(-90,0,90)*iprofile(w3), \
|
||||
Pos(w2/2,0,60)*Rot(-90,0,90)*iprofile(w3), \
|
||||
]
|
||||
show(*profiles)#, hopperblock)
|
||||
# %%
|
||||
#ASSEMBLY
|
||||
extruder = Compound(label="Extruder",children=[rodcollector.part,cylindercollector.part,nozzleplate.part,\
|
||||
pumpcylinderblock.part,pumpcylinderrods.part,pumpcylinders.part,hopper.part])
|
||||
extruder=Pos(120,170,168)*Rot(45,0,0)*extruder
|
||||
#extruder.translate((hp/2,0,0))
|
||||
show(*profiles,extruder)#, pumpcylindercutout)# %%
|
||||
|
||||
# %%
|
||||
railpath = "/home/hbrs/Downloads/8381K54_Miniature Ball Bearing Carriage and Guide Rail.STEP"
|
||||
carriagepath = "/home/hbrs/Downloads/6725K531_12 mm Wide x 200 mm Long Rail for Ball Bearing Carriage.STEP"
|
||||
|
||||
rail = import_step(railpath)
|
||||
carriage = import_step(carriagepath)
|
||||
show(carriage)
|
||||
# %%
|
||||
#cmpds = rail.compound()
|
||||
shapes = rail.entities(topo_type=Part)
|
||||
# %# %%
|
||||
|
||||
len(shapes)# %%
|
||||
|
||||
# %%
|
||||
|
||||
# %%
|
||||
with BuildPart() as iprofile_angle:
|
||||
with Locations((0,10,0)):
|
||||
Box(40,20,20,rotation=(45,0,0))
|
||||
with Locations((0,10,-10)):
|
||||
Box(40,30,20,rotation=(0,0,0),mode=Mode.SUBTRACT)
|
||||
with BuildSketch() as profile:
|
||||
Rectangle(40,10)
|
||||
extrude(amount=5)
|
||||
with Locations((5,0,0),(20,0,0)):
|
||||
|
||||
|
||||
ppr=Pos(20,0,0)*Rot(-90,0,90)*iprofile(w3)
|
||||
show(ppr,iprofile_angle)
|
||||
|
||||
# %%
|
||||
258
pretiosius.py
258
pretiosius.py
@ -1,258 +0,0 @@
|
||||
#%%
|
||||
from build123d import *
|
||||
from ocp_vscode import *
|
||||
from math import sin, cos, pi
|
||||
|
||||
import copy
|
||||
set_defaults(reset_camera=Camera.KEEP, render_joints=True, helper_scale=8)
|
||||
# %%
|
||||
y = 120
|
||||
height = 6
|
||||
pad = 2
|
||||
s = 0.8
|
||||
s1 = 0.7
|
||||
#%%
|
||||
with BuildPart() as ring:
|
||||
with BuildSketch(Plane.XY) as sk:
|
||||
with BuildLine() as outline:
|
||||
c1 = Bezier((-pad,y,0),(-pad,y+3,0),(height+pad,y+3,0),(height+pad, y, 0))
|
||||
c2 = Bezier((-pad,y,0),(-pad,y-2,0),(height+pad,y-2,0),(height+pad, y, 0))
|
||||
|
||||
#c1 = Spline([(-pad,y,0),(height+pad,y,0)], tangents=[(0,1),( 0,-1)], tangent_scalars=[s,s])
|
||||
#c2 = Spline([(-pad,y,0),(height+pad,y,0)], tangents=[(0,-1),(0,1)], tangent_scalars=[s1,s1])
|
||||
|
||||
make_face()
|
||||
revolve(axis=Axis.X)
|
||||
|
||||
show(ring,outline)
|
||||
|
||||
# %%
|
||||
outer_ring_surface = Face.revolve(c1, 360, Axis.X)
|
||||
# cut ring in half and use the outer edge that got created by the cut
|
||||
#outer_ring_path = (copy.copy(ring.part)-(Pos(X=10+height/2)*Box(20,50,50))).edges().sort_by(Axis.X)[-1]
|
||||
outer_ring_path = ring.part.edges().sort_by(Axis.X)[0]
|
||||
|
||||
show(ring,outer_ring_surface,outer_ring_path)
|
||||
|
||||
# %%
|
||||
def sinus_signal(periods, width, height,n):
|
||||
dw = (width) / (n-1)
|
||||
dphi = periods * 2 * pi / (n-1)
|
||||
t = 0.5 # thickness
|
||||
pts = [( t+0.1+dw*i, t+0.1+(height/2)*(1+sin(dphi*i))) for i in range(n)]
|
||||
with BuildSketch() as sk:
|
||||
with BuildLine() as signal:
|
||||
Polyline(pts)
|
||||
offset(amount=t)
|
||||
make_face()
|
||||
return sk
|
||||
|
||||
sig = sinus_signal(1,outer_ring_path.length/3, 5, 60)
|
||||
show(sig)
|
||||
#%%
|
||||
wrapped_sig = outer_ring_surface.wrap_faces(sig.faces(), outer_ring_path)
|
||||
|
||||
show(ring, wrapped_sig)
|
||||
|
||||
# %%
|
||||
width = 3
|
||||
|
||||
ri = 10
|
||||
rm = ri+2
|
||||
ro = ri+4
|
||||
|
||||
|
||||
p = Pos(ri,0,0)
|
||||
|
||||
def string_to_binary_string(s:str):
|
||||
return ''.join(["{0:08b}".format(ord(c)) for c in s])
|
||||
|
||||
def build_signal2D(binstring, width):
|
||||
hheight = height - 1
|
||||
print(f"{width=} {hheight=}")
|
||||
n = len(binstring)
|
||||
dw = width/n
|
||||
h = 0.5 if binstring[0] == "0" else hheight
|
||||
pts = [(h,+ 0.5)]
|
||||
for i, b in enumerate(binstring):
|
||||
pos_flank = (b == "0" and binstring[(i+1)%n] == "1")
|
||||
neg_flank = (b == "1" and binstring[(i+1)%n] == "0")
|
||||
#print(f"{pos_flank*1}{neg_flank*1}")
|
||||
if pos_flank or neg_flank:
|
||||
x = dw*(1+i) if i < len(binstring)-1 else dw*(1+i) -0.5
|
||||
pts.append((h,x))
|
||||
#print(f"- {i} {b}")
|
||||
if pos_flank:
|
||||
h = hheight
|
||||
#print(f"^ {i} {b}")
|
||||
pts.append((h,x))
|
||||
if neg_flank:
|
||||
#print(f"v {i} {b}")
|
||||
h = 0.5
|
||||
pts.append((h,x))
|
||||
#print(f"{pts = }")
|
||||
with BuildSketch() as sk:
|
||||
with BuildLine() as signal:
|
||||
Polyline(pts)
|
||||
offset(amount=0.4)
|
||||
make_face()
|
||||
#rrr = Rectangle(width, height,mode=Mode.PRIVATE)
|
||||
return sk
|
||||
|
||||
# %%
|
||||
sig = build_signal2D("100010",outer_ring_path.length-0.0)
|
||||
show(sig.face())
|
||||
# %%
|
||||
wrapped_sig = outer_ring_surface.wrap_faces(sig.faces(), outer_ring_path)
|
||||
|
||||
show(ring, wrapped_sig)
|
||||
#show(sig)
|
||||
|
||||
|
||||
# %%
|
||||
def build_signal_A(binstring, ri):
|
||||
n = len(binstring)
|
||||
ro = ri+1
|
||||
dphi =2*pi/(n+0)
|
||||
dp = dphi/10
|
||||
dh = min(dp*ro, 18*pi/180)
|
||||
|
||||
a = 1
|
||||
tngu = lambda phi, d: (a*cos(phi), a*sin(phi), d)
|
||||
tngd = lambda phi, d: (-a*cos(phi), -a*sin(phi), d)
|
||||
|
||||
with BuildPart() as signal:
|
||||
with BuildLine(Plane.XY) as path_builder:
|
||||
segments = []
|
||||
h = 0 if binstring[0] == "0" else height
|
||||
same_bits_streak = 0
|
||||
for i, b in enumerate(binstring):
|
||||
pos_flank = (b == "0" and binstring[(i+1)%n] == "1")
|
||||
neg_flank = (b == "1" and binstring[(i+1)%n] == "0")
|
||||
same_bits_streak += 1
|
||||
if neg_flank or pos_flank or (i == n-1):
|
||||
phi0 = dphi*(i-same_bits_streak+1)
|
||||
phi1 = dphi*(i-same_bits_streak+1+0.5*same_bits_streak)
|
||||
phi2 = dphi*(i+1)
|
||||
phi0_pad = phi0 + dp
|
||||
phi2_pad = phi2 - dp
|
||||
#if segments:
|
||||
# segments.append(Spline(segments[-1]@1,p1, tangents=[segments[-1]%1, tngu(phi2, -1)]))
|
||||
segments.append(ThreePointArc(
|
||||
(ri * cos(phi0_pad), ri * sin(phi0_pad),h),
|
||||
(ri * cos(phi1), ri * sin(phi1),h),
|
||||
(ri * cos(phi2_pad), ri * sin(phi2_pad),h),
|
||||
))
|
||||
same_bits_streak = 0
|
||||
p1 = (ri * cos(phi2), ri * sin(phi2),height-dh)
|
||||
p2 = (ri * cos(phi2), ri * sin(phi2),dh)
|
||||
#l = segments[i]
|
||||
if neg_flank:
|
||||
h = 0
|
||||
segments.append(Spline(segments[-1]@1,p1, tangents=[segments[-1]%1, tngu(phi2, -1)]))
|
||||
segments.append(Spline(p1,p2,
|
||||
tangents=[tngu(phi2, -1), tngd(phi2, -1)]))
|
||||
if pos_flank:
|
||||
h = height
|
||||
segments.append(Spline(p2,p1,
|
||||
tangents=[tngu(phi2, 1), tngd(phi2, 1)]))
|
||||
|
||||
# l1 = segments[0]
|
||||
with BuildSketch(Plane( segments[0] @ 0, z_dir=segments[0] % 0)) as x_section:
|
||||
Circle(0.5)
|
||||
#return path_builder
|
||||
sweep(transition=Transition.ROUND)
|
||||
return signal
|
||||
|
||||
|
||||
|
||||
|
||||
def build_signal_B(binstring, ri):
|
||||
n = len(binstring)
|
||||
ro = ri+1
|
||||
dphi =2*pi/(n+0) # how much angle per bit
|
||||
dp = 0.81/ri/pi#dphi/10 # how much of that used for curvature
|
||||
dh = min(dp*ro, 10*pi/180)
|
||||
|
||||
a = 1
|
||||
tngu = lambda phi, d: (a*cos(phi), a*sin(phi), d)
|
||||
tngd = lambda phi, d: (-a*cos(phi), -a*sin(phi), d)
|
||||
|
||||
def build_segments(pre_segments=[]):
|
||||
segments = []
|
||||
h = 0 if binstring[0] == "0" else height
|
||||
same_bits_streak = 0
|
||||
i_hoz = 0
|
||||
ns = len(pre_segments)
|
||||
for i, b in enumerate(binstring):
|
||||
pos_flank = b == "0" and binstring[(i+1)%n] == "1"
|
||||
neg_flank = b == "1" and binstring[(i+1)%n] == "0"
|
||||
same_bits_streak += 1
|
||||
if neg_flank or pos_flank or (i == n-1):
|
||||
phi0 = dphi*(i-same_bits_streak+1)
|
||||
phi1 = dphi*(i-same_bits_streak+1+0.5*same_bits_streak)
|
||||
phi2 = dphi*(i+1)
|
||||
phi0_pad = phi0 + dp
|
||||
phi2_pad = phi2 - dp
|
||||
#if segments:
|
||||
# segments.append(Spline(segments[-1]@1,p1, tangents=[segments[-1]%1, tngu(phi2, -1)]))
|
||||
segments.append(ThreePointArc(
|
||||
(ri * cos(phi0_pad), ri * sin(phi0_pad),h),
|
||||
(ri * cos(phi1), ri * sin(phi1),h),
|
||||
(ri * cos(phi2_pad), ri * sin(phi2_pad),h),
|
||||
))
|
||||
i_hoz += 1
|
||||
same_bits_streak = 0
|
||||
p1 = (ri * cos(phi2), ri * sin(phi2),height-dh)
|
||||
p2 = (ri * cos(phi2), ri * sin(phi2),dh)
|
||||
#l = segments[i]
|
||||
if neg_flank:
|
||||
h = 0
|
||||
if pre_segments:
|
||||
segments.append(Spline(pre_segments[i_hoz-1]@1,p1, tangents=[pre_segments[i_hoz-1]%1, tngu(phi2, -1)]))
|
||||
segments.append(Spline(p1,p2,
|
||||
tangents=[tngu(phi2, -1), tngd(phi2, -1)]))
|
||||
segments.append(Spline(p2, pre_segments[i_hoz%ns]@0, tangents=[tngd(phi2, -1), pre_segments[i_hoz%ns]%0]))
|
||||
if pos_flank:
|
||||
h = height
|
||||
if pre_segments:
|
||||
segments.append(Spline(pre_segments[i_hoz-1]@1,p2, tangents=[pre_segments[i_hoz-1]%1, tngu(phi2, 1)]))
|
||||
segments.append(Spline(p2,p1,
|
||||
tangents=[tngu(phi2, 1), tngd(phi2, 1)]))
|
||||
segments.append(Spline(p1, pre_segments[i_hoz%ns]@0, tangents=[tngd(phi2, 1), pre_segments[i_hoz%ns]%0]))
|
||||
|
||||
return segments
|
||||
|
||||
pre_segments = build_segments()#???
|
||||
|
||||
|
||||
with BuildPart() as signal:
|
||||
with BuildLine(Plane.XY) as path_builder:
|
||||
#path_builder.mode=Mode.PRIVATE
|
||||
segments = build_segments(pre_segments)
|
||||
#segments = build_segments()
|
||||
# l1 = segments[0]
|
||||
with BuildSketch(Plane(segments[0] @ 0, z_dir=segments[0] % 0)) as x_section:
|
||||
Circle(0.4)
|
||||
#Rectangle(0.8,0.8)
|
||||
#return path_builder
|
||||
sweep()
|
||||
#sweep(transition=Transition.ROUND)
|
||||
signal.label="decor"
|
||||
#return pre_segments
|
||||
return path_builder
|
||||
#return signal
|
||||
|
||||
# %%
|
||||
#binstr = '0101100'#
|
||||
#binstr = '110101000'#
|
||||
binstr = string_to_binary_string("munsel")
|
||||
#binstr = string_to_binary_string("nonpostrans")
|
||||
signal = build_signal_B(binstr, ri+width+0.3)
|
||||
#show(signal,ring, transparent=True)
|
||||
show(signal, transparent=True)
|
||||
|
||||
|
||||
#%%
|
||||
product = Compound(label="ring", children=[ring.part, signal.part])
|
||||
show(product)
|
||||
@ -1,62 +0,0 @@
|
||||
def build_psorias_release(L = 216, W = 127, H = 135,PEAK2PEAK = 160, h_bottom = 15):
|
||||
|
||||
R0 = 40
|
||||
R1 = 8
|
||||
R2 = 40
|
||||
R3 = 30
|
||||
w_cut_inside = (PEAK2PEAK / 2) - R1-1
|
||||
w_cut_outside = (L / 2) - w_cut_inside - (2 * R1)
|
||||
print(f"{w_cut_inside = } {w_cut_outside = }")
|
||||
|
||||
h_bend = 70
|
||||
w_bend = w_cut_outside - 8
|
||||
h_rect = 10
|
||||
w_slope = 10
|
||||
|
||||
|
||||
with BuildPart() as p:
|
||||
with BuildSketch(Plane.XZ) as s:
|
||||
with Locations((0,H-R0)):
|
||||
Circle(R0)
|
||||
with Locations((0,0)):
|
||||
Rectangle(W, h_rect)
|
||||
make_hull()
|
||||
extrude(amount=L/2)
|
||||
with BuildSketch(Plane.YZ.offset(-W/2)) as s:
|
||||
with Locations((-(L-w_cut_inside)/2, H+h_rect/2)):
|
||||
Rectangle(w_cut_inside, h_rect)
|
||||
with Locations(((-L+w_cut_inside-w_slope-R2-1)/2, h_bottom+h_rect/2)):
|
||||
Rectangle(w_cut_inside-w_slope-R2, h_rect)
|
||||
with Locations((-(L-w_cut_inside+R2-w_slope)/2, h_bottom+R2)):
|
||||
Circle(R2)
|
||||
make_hull()
|
||||
extrude(amount=W, mode=Mode.SUBTRACT)
|
||||
with BuildSketch(Plane.YZ.offset(-W/2)) as s:
|
||||
with Locations((-w_cut_outside/2, H+h_rect/2)):
|
||||
Rectangle(w_cut_outside, h_rect)
|
||||
with Locations(((h_rect)/2, h_rect)):
|
||||
Rectangle(h_rect, h_rect)
|
||||
with Locations((-w_bend+R3, h_bend)):
|
||||
Circle(R3)
|
||||
make_hull()
|
||||
extrude(amount=W, mode=Mode.SUBTRACT)
|
||||
fillet(p.edges().sort_by(Axis.Z)[-1], radius=R1)
|
||||
fillet(p.edges().sort_by(Axis.Z)[-3], radius=R1)
|
||||
#scale(by=(1,1,0.8), mode=Mode.SUBTRACT)
|
||||
mirror(p.part, about=Plane(p.faces().group_by(Axis.Y)[0][0]))
|
||||
return p
|
||||
|
||||
p = build_psorias_release()
|
||||
p1 = build_psorias_release(L = 216, W = 110, H = 100,PEAK2PEAK = 160, h_bottom = 15)
|
||||
p2 = p.part - p1.part.locate(Location((0.,0,-25.)))
|
||||
|
||||
p2
|
||||
|
||||
# %%
|
||||
p1 = copy.copy(p.part)
|
||||
p1 = scale(p1, by=(0.8,0.95,0.8)).locate(Location((0.,-(1-0.95)*W/2.-2.5,-25.)))
|
||||
p2 = p.part-p1
|
||||
|
||||
p2.export_step("psoas_releaser.step")
|
||||
|
||||
|
||||
245
water_blesser.py
245
water_blesser.py
@ -1,245 +0,0 @@
|
||||
#%%
|
||||
from build123d import *
|
||||
from ocp_vscode import *
|
||||
#from bd_animation import AnimationGroup, clone, normalize_track
|
||||
|
||||
import copy
|
||||
set_defaults(reset_camera=Camera.KEEP, render_joints=True, helper_scale=8)
|
||||
|
||||
|
||||
se = 30
|
||||
sc = 14
|
||||
with BuildPart() as electrode_holder:
|
||||
with BuildSketch() as sk:
|
||||
Rectangle(se,se,rotation=0)
|
||||
with GridLocations(se,se,2,2):
|
||||
Circle(3)
|
||||
Circle(1.25, mode=Mode.SUBTRACT)
|
||||
with PolarLocations(se/2,4):
|
||||
Rectangle(sc,sc,45,mode=Mode.SUBTRACT)
|
||||
Circle(8)
|
||||
with PolarLocations(se/2,4, 45):
|
||||
with Locations((10,0)):
|
||||
Rectangle(8,1.7, mode=Mode.SUBTRACT)
|
||||
with Locations((-4,0)):
|
||||
Rectangle(12,3, mode=Mode.SUBTRACT)
|
||||
fillet(sk.vertices(),radius=1.3)
|
||||
#fillet(sk.vertices(),radius=0.3)
|
||||
Rectangle(3,3,mode=Mode.SUBTRACT)
|
||||
extrude(amount=3)
|
||||
|
||||
show(electrode_holder)
|
||||
# %%
|
||||
lg,wg = 43,22
|
||||
bg = 3
|
||||
with BuildPart() as arm:
|
||||
with BuildSketch() as sk:
|
||||
with BuildLine() as ll:
|
||||
l1=JernArc((0,0),(0,1),80,-135)
|
||||
Line(l1 @ 1, l1 @ 1 + (6, -4))
|
||||
offset(amount=bg/2)
|
||||
make_face()
|
||||
with BuildLine() as lll:
|
||||
Spline((0,-wg),l1@1,tangents=[(0,1),l1%1],tangent_scalars=(1,1))
|
||||
offset(amount=bg/2)
|
||||
make_face()
|
||||
with Locations((-lg/2-bg/2,-wg/2)):
|
||||
Rectangle(lg+2*bg,wg+2*bg)
|
||||
with Locations((0,bg/2)):
|
||||
Rectangle(lg,wg+bg,mode=Mode.SUBTRACT)
|
||||
with Locations((20,-30)):
|
||||
Circle(5)
|
||||
Circle(2.6,mode=Mode.SUBTRACT)
|
||||
with BuildLine() as llll:
|
||||
FilletPolyline((-lg,-wg-bg/2),(32,-37),(0,0),radius=5)
|
||||
offset(amount=bg/2)
|
||||
make_face()
|
||||
extrude(amount=3)
|
||||
|
||||
show(arm.part)
|
||||
# %%
|
||||
export_step(arm.part, "arrm.step")
|
||||
export_stl(arm.part,"arm.stl")
|
||||
# %%
|
||||
export_step(electrode_holder.part, "electrodeholder.step")
|
||||
# %%
|
||||
wp=27
|
||||
dp=15.5
|
||||
hp = 14
|
||||
tp=2
|
||||
with BuildPart() as psu_holder:
|
||||
Box(wp+2*tp,dp+2*tp,hp+tp)
|
||||
with Locations((dp/2,0,tp/2)):
|
||||
Box(wp-10,dp,hp,mode=Mode.SUBTRACT)
|
||||
with Locations((-4.5/2,0,0.5)):
|
||||
Cylinder(13/2, 4.5,rotation=(0,90,0),mode=Mode.SUBTRACT)
|
||||
with Locations((-4.5/2,0,7)):
|
||||
Box(4.5,13,hp,mode=Mode.SUBTRACT)
|
||||
with Locations((-wp/2+3.2/2-tp,0,tp/2)):
|
||||
Box(3.2,9,hp,mode=Mode.SUBTRACT)
|
||||
|
||||
|
||||
show(psu_holder)
|
||||
|
||||
# %%
|
||||
rg=74
|
||||
rg1=83
|
||||
rg2=68
|
||||
rgr=2
|
||||
|
||||
with BuildPart() as glassholder_rod:
|
||||
with BuildLine(Plane.XZ) as ghp:
|
||||
FilletPolyline((rg/2+rgr,3),(rg/2+rgr,10),(rg/4,20),(rg/4,60),(rg1/2+rgr,114),\
|
||||
(rg2/2+rgr,200),radius=10)
|
||||
with BuildSketch(Plane((rg/2+rgr,0,0),z_dir=(0,0,1))):
|
||||
Rectangle(rgr*2,rgr*2)
|
||||
sweep()
|
||||
# lower screw mounts
|
||||
with BuildSketch():
|
||||
with Locations((rg/2,-2)):
|
||||
Circle(6)
|
||||
with Locations((rg/2+2,-4)):
|
||||
Circle(1.55,mode=Mode.SUBTRACT)
|
||||
extrude(amount=3)
|
||||
# upper screw mounts
|
||||
with BuildSketch(Plane.XY.offset(197)):
|
||||
with Locations((rg/2,-2)):
|
||||
Circle(6)
|
||||
with Locations((rg/2+2,-4)):
|
||||
Circle(1.55,mode=Mode.SUBTRACT)
|
||||
extrude(amount=3)
|
||||
Cylinder(rg/2,6,mode=Mode.SUBTRACT)
|
||||
with Locations((0,0,197)):
|
||||
Cylinder(rg2/2,6,mode=Mode.SUBTRACT)
|
||||
with Locations((rg2/2,8)):
|
||||
Box(30,12,500,mode=Mode.SUBTRACT)
|
||||
#with Locations((0,0,200))
|
||||
show(glassholder_rod, ghp)
|
||||
# %%
|
||||
export_step(glassholder_rod.part, 'glassholder_rod.step')
|
||||
|
||||
# %%
|
||||
with BuildPart() as glass_holder_base:
|
||||
with BuildSketch() as sk:
|
||||
Circle(rg/2+2)
|
||||
extrude(amount=4.5)
|
||||
with BuildSketch(Plane.XY.offset(4.5)) as sk:
|
||||
Circle(rg/2+2)
|
||||
with BuildSketch(Plane.XY.offset(15)) as sk:
|
||||
Circle(6)
|
||||
loft()
|
||||
with Locations((0,0,8.5)):
|
||||
Cylinder(rg/2-4,15,mode=Mode.SUBTRACT)
|
||||
with Locations((0,0,2.5)):
|
||||
Cylinder(rg/2,3,mode=Mode.SUBTRACT)
|
||||
with Locations((-rg/4-1,0,6)):
|
||||
Box(rg/2+2,rg+4,10,mode=Mode.SUBTRACT)
|
||||
fillet(glass_holder_base.edges().group_by(Axis.Z)[5].filter_by(GeomType.CIRCLE), radius=1.6)
|
||||
Cylinder(rg/2-10, 2,mode=Mode.SUBTRACT)
|
||||
|
||||
with PolarLocations(rgr,3):
|
||||
with Locations((rg/2,-2,0)):
|
||||
Cylinder(6,1,align=[Align.CENTER,Align.CENTER,Align.MIN])
|
||||
with Locations((rg/2+2,-4)):
|
||||
Cylinder(1.55,10,mode=Mode.SUBTRACT)
|
||||
show(glass_holder_base)
|
||||
# %%
|
||||
export_step(glass_holder_base.part, 'glassholder_base.step')
|
||||
|
||||
#%%
|
||||
with BuildPart() as glassholder_top:
|
||||
with BuildSketch(Plane.XY.offset(200)):
|
||||
Circle(rg2/2+rgr*2)
|
||||
with Locations((-rg2/2+6,0)):
|
||||
Rectangle(14,rg)
|
||||
Circle(rg2/2,mode=Mode.SUBTRACT)
|
||||
with PolarLocations(rgr,3):
|
||||
with Locations((rg2/2,-2,0)):
|
||||
Circle(6)
|
||||
with Locations((rg2/2+2,-4)):
|
||||
Circle(1.55,mode=Mode.SUBTRACT)
|
||||
extrude(amount=4)
|
||||
with Locations((-rg2/2+4,-rg2/2-5,202),(-rg2/2+4,rg2/2+5,202)):
|
||||
Cylinder(5.6/2, 20, rotation=(90,0,0))
|
||||
Cylinder(rg2/2, 500, mode=Mode.SUBTRACT)
|
||||
with Locations((0,0,205),(0,0,199)):
|
||||
Box(120,120,2,mode=Mode.SUBTRACT)
|
||||
|
||||
show(glassholder_top)
|
||||
# %%
|
||||
export_step(glassholder_top.part, "glassholder_top.step")
|
||||
|
||||
#%%
|
||||
with BuildPart() as glassstem_holder:
|
||||
with Locations((-8.5,0,0)):
|
||||
Box(10,rg/2,2)
|
||||
with PolarLocations(rg/4+2, 3):
|
||||
Box(4,4,100,mode=Mode.SUBTRACT)
|
||||
fillet(glassstem_holder.edges().group_by(Axis.X)[-1].filter_by(Axis.Z), radius=4)
|
||||
|
||||
show(glassstem_holder)
|
||||
export_step(glassstem_holder.part, "glassstem_holder.step")
|
||||
# %%
|
||||
with BuildPart() as glass_holder:
|
||||
add(glass_holder_base)
|
||||
with PolarLocations(rgr,3):
|
||||
add(copy.copy(glassholder_rod))
|
||||
add(glassholder_top)
|
||||
with Locations((0,0,50)):
|
||||
add(glassstem_holder)
|
||||
|
||||
|
||||
|
||||
|
||||
show(glass_holder)
|
||||
# %%
|
||||
show(glass_holder.edges().group_by(Axis.Z)[5].filter_by(GeomType.CIRCLE))
|
||||
# %%
|
||||
def splintgen(m=1.45,h=7.2):
|
||||
with BuildPart() as snapfit_splint:
|
||||
with BuildSketch() as sn_sk:
|
||||
with BuildLine():
|
||||
Polyline((0,0),(m+0.5,0),(m+0.5,1),(m,1),(m,h),(m+0.5,h),(m+0.5,h+0.5),\
|
||||
(m,h+m),(m/2,h+m),(0,m*3),close=True)
|
||||
make_face()
|
||||
mirror(about=Plane.YZ)
|
||||
extrude(amount=m)#50% radius
|
||||
return snapfit_splint
|
||||
|
||||
m3x7_splint = splintgen(h=8.5)
|
||||
show(m3x7_splint)
|
||||
#%%
|
||||
export_step(m3x7_splint.part, "m3x8_splint.step")
|
||||
|
||||
# %%
|
||||
with BuildPart() as bearing_mount:
|
||||
d=19.4
|
||||
t = 1
|
||||
Cylinder(d/2+t,7+1)
|
||||
#Cylinder(d/2,7,mode=Mode.SUBTRACT)
|
||||
#Cylinder(d/2-1,9,mode=Mode.SUBTRACT)
|
||||
with Locations((-d/2-t,0,4.5)):
|
||||
Box(1,36,17)
|
||||
fillet(bearing_mount.edges(Select.NEW).filter_by(Axis.Z),radius=7)
|
||||
Cylinder(d/2,7,mode=Mode.SUBTRACT)
|
||||
Cylinder(d/2-1,9,mode=Mode.SUBTRACT)
|
||||
with Locations((-d/2-t,0,28.5)):
|
||||
Box(1,80,40)
|
||||
fillet(bearing_mount.edges(Select.NEW).filter_by(Axis.X),radius=10)
|
||||
|
||||
with BuildSketch(Plane.YZ.offset(-d/2-t)):
|
||||
with Locations((0,28.5)):
|
||||
with GridLocations(12,6,6,6):
|
||||
RectangleRounded(10,4,1)
|
||||
with GridLocations(75,10,2,4):
|
||||
Circle(1.5)
|
||||
extrude(amount=2,mode=Mode.SUBTRACT,both=True)
|
||||
|
||||
with Locations((d/2,0,0)):
|
||||
Box(10,10,10,mode=Mode.SUBTRACT)
|
||||
fillet(bearing_mount.edges(Select.NEW).filter_by(Axis.Z).group_by(Axis.X)[-1],radius=0.5)
|
||||
|
||||
show(bearing_mount)
|
||||
# %%
|
||||
export_step(bearing_mount.part, "bearing_mount.step")
|
||||
# %%
|
||||
Loading…
Reference in New Issue
Block a user