diff --git a/balcony_hook2.py b/balcony_hook2.py new file mode 100644 index 0000000..347cbfa --- /dev/null +++ b/balcony_hook2.py @@ -0,0 +1,35 @@ +import copy +from build123d import * +from ocp_vscode import show + + +ro = 70 +wt=5 +h = 100 + +with BuildPart() as part_builder: + with BuildSketch() as sk: + Circle(ro) + extrude(amount=h) + with Locations((0,ro, 20)): + Box(ro*2-20, 70, 40) + with Locations((0,25,0)): + Box(wt*2, 20, 50, mode=Mode.SUBTRACT) + with Locations((0,15,0)): + Box(ro*2-20-wt*4, wt*2, 60, mode=Mode.SUBTRACT) + with Locations((0,15+wt*3,-10)): + Box(ro*2-20-wt*4, wt*4, 20, mode=Mode.SUBTRACT) + with BuildSketch(part_builder.faces().sort_by(Axis.Z)[-1 + ]) as sk: + Circle(ro-wt) + extrude(amount=-(h-wt), mode=Mode.SUBTRACT) + fillet(part_builder.edges().group_by(Axis.Z)[-1], radius=wt/2-0.001) + + + +show(part_builder) + + + + + diff --git a/drops.py b/drops.py index 5005f54..2a1cdee 100644 --- a/drops.py +++ b/drops.py @@ -92,7 +92,7 @@ show(mold_for_mold) # %% nHoles = 10 -vol_ml = 0.3 # millilitiers = 1/1000 * 10cm*10cm*10cm = 100mm*100mm*100mm/1000 = 1000mm³ +vol_ml = 1.0 # millilitiers = 1/1000 * 10cm*10cm*10cm = 100mm*100mm*100mm/1000 = 1000mm³ vol = vol_ml * 1000 r = 4 # millimeters ri = 2 @@ -100,33 +100,69 @@ rrod=1 rodlen=100 tol = 0.05 A = 3.14*r*r -t = vol/A # liter/meter +t = 2*vol/A # liter/meter wt = 1 -l, w, h = (r+wt)*2, (r*2+wt)*(nHoles+0.5), t+4 +l, w, h = (r*2+wt)*(nHoles+0.5)+8, t+8, (r+wt)*2 with BuildPart() as pumpcylindercutout: - with BuildSketch() as holes_sk: + with BuildSketch(Plane.XZ) as holes_sk: Circle(r) extrude(amount=t) - with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Z)[0]) as rodhole_sk: + with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Y)[0]) as rodhole_sk: Circle(rrod+tol) extrude(amount=10) - chamfer(pumpcylindercutout.edges().sort_by(Axis.Z)[3],2) -show(pumpcylindercutout) + 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=100 + rodlen=60 #Cylinder(3,4) #with Locations((0,0,rodlen/2-10)): # Cylinder(rrod,rodlen) - with BuildSketch(Plane.YZ) as sk: + with BuildSketch(Plane.XY) as sk: with BuildLine() as outline: d=2 hn=1 @@ -138,45 +174,170 @@ with BuildPart() as pumpvalverod: l6=CenterArc((0,rodlen),rrod,0,90) l7=Line(l6@1,l1@0) make_face() - revolve() - fillet(pumpvalverod.edges().sort_by(Axis.Z)[5],0.5) - with Locations((0,0,rodlen-3.5),(0,0,rodlen-11.5)): + 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,7,4, mode=Mode.SUBTRACT) + Box(rrod,3,4, mode=Mode.SUBTRACT) + show(pumpvalverod) + + # %% with BuildPart() as pumpcylinder: - rodlen=80 - Cylinder(r, rodlen) - with Locations((0,0,-rodlen/2+t/2)): - Cylinder(ri, t,mode=Mode.SUBTRACT) - #chamfer(pumpcylinder.edges()[4],1) - with Locations((0,0,t/2)): - Box(ri*2,r*2,rodlen-t,mode=Mode.SUBTRACT) - with Locations((0,0,-rodlen/2+t+1)): - Box(ri*2,r*3,r*3,rotation=(45,0,0), mode=Mode.SUBTRACT) - Box(ri*2,r*3,r*3, mode=Mode.SUBTRACT) - with Locations((0,-ri-1,-2),(0,ri+1,-2)): - Box(r*2,ri+2,rodlen-t-4,mode=Mode.SUBTRACT) - #s=pumpcylinder.edges().group_by(Axis.Z)[2] - #filter_by(GeomType.CIRCLE,reverse=True)#.filter_by(Axis.X.is_parallel) - #fillet( s[0:2],1) - chamfer(pumpcylinder.edges().group_by(Axis.Z)[0][1],1) + 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) -#%% +show(pumpcylinder,pumpvalverod) -with BuildPart() as pumpcylinderblock: - Box(l,w,h) - f = pumpcylinderblock.faces()[5].offset(-t) - #with GridLocations() - with Locations((0,0,h/2-t)): - with GridLocations(0,r+wt+r,1,nHoles): - 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)) -show(pumpcylinderblock) + #%% +# 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 @@ -206,49 +367,13 @@ with BuildPart() as standfoot: #extrude(amount=4) #offset(amount=-1.9, openings=[stand.faces().sort_by(Axis.Z)[-1]]) -show(standfoot) -#%% -with BuildPart() as pumpcylinderrods: - with Locations((0,0,h/2-t-2-rrod)): - with GridLocations(0,r+wt+r,1,nHoles): - add(copy.copy(pumpvalverod)) - -with BuildPart() as pumpcylinders: - with Locations((0,0,h/2-t+rodlen/2)): - with GridLocations(0,r+wt+r,1,nHoles): - add(copy.copy(pumpcylinder),rotation=(0,0,90)) - LinearJoint("cylinders", axis=Axis.Z, linear_range=(-t, t)) -pumpcylinderblock.part.joints["slide"].connect_to(pumpcylinders.joints["cylinders"]) - - -show(pumpcylinderblock,stand,pumpcylinderrods,pumpcylinders,render_joints=True)#, pumpcylindercutout)# %% - +show(standfoot) # %% -pumpcylinder.edges().group_by(Axis.Z)[1] -# %% -with BuildPart() as hopper: - with BuildSketch(Plane.XY.offset(h/2)) as down_sk: - RectangleRounded(l,w,4) - with BuildSketch(Plane.XY.offset(60)) as up_sk: - with Locations((20,0)): - RectangleRounded(l+50,w+50, 8) - loft() - offset(amount=-0.5, openings=[hopper.faces().sort_by(Axis.Z)[0],\ - hopper.faces().sort_by(Axis.Z)[-1]]) -#show(hopper) -show(pumpcylinderblock,pumpcylinderrods,pumpcylinders,hopper,render_joints=True)#, pumpcylindercutout)# %% - -# %% -show(hopper,hopper.faces().sort_by(Axis.Z)[-1]) -# %% -hopperblock = pumpcylinderblock.part + hopper.part -show(hopperblock) -# %% -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") +#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) @@ -260,8 +385,6 @@ with BuildPart() as idb_holder: fillet(idb_holder.edges().group_by(Axis.Z)[-1].filter_by(GeomType.LINE)[0], radius=1.5) show(idb_holder) # %% -show(idb_holder, idb_holder.edges().group_by(Axis.Z)[-1].filter_by(GeomType.LINE)[0]) -# %% export_step(idb_holder.part, "idb_holder.step") # %% @@ -300,5 +423,27 @@ profiles= [ \ ] 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]) +# %%