Fix BK12 model
This commit is contained in:
parent
8e7fe382d2
commit
d71cbf1391
150
utils.py
150
utils.py
|
@ -5,6 +5,7 @@ from ocp_vscode import *
|
|||
|
||||
import localselectors
|
||||
|
||||
|
||||
class SFU1204:
|
||||
def __init__(self, base, l):
|
||||
self.w = base.workplane()
|
||||
|
@ -32,41 +33,45 @@ class SFU1204:
|
|||
|
||||
def nut(self, x):
|
||||
w = self.w.transformed(offset=(0, x, 0), rotate=(90, 0, 0))
|
||||
n = (w.sketch()
|
||||
n = (
|
||||
w.sketch()
|
||||
.circle(40 / 2)
|
||||
.circle(12/2, mode='s')
|
||||
.rect(42, 30, mode='i')
|
||||
.circle(12 / 2, mode="s")
|
||||
.rect(42, 30, mode="i")
|
||||
.finalize()
|
||||
.extrude(10)
|
||||
.faces(">z")
|
||||
.copyWorkplane(w)
|
||||
.transformed(offset=(0, 0, 10))
|
||||
.workplane()
|
||||
.tag("nut_face")
|
||||
.sketch()
|
||||
.circle(22 / 2)
|
||||
.circle(12/2, mode='s')
|
||||
.circle(12 / 2, mode="s")
|
||||
.finalize()
|
||||
.extrude(25))
|
||||
.extrude(25)
|
||||
)
|
||||
hole_r = 32 / 2
|
||||
hole_pts = [
|
||||
(hole_r*math.cos(angle*math.pi/180),
|
||||
hole_r*math.sin(angle*math.pi/180)) for angle in
|
||||
[-45, 0, 45, 180-45, 180, 180+45]]
|
||||
n = (n.workplaneFromTagged("nut_face")
|
||||
.pushPoints(hole_pts)
|
||||
.hole(4.8)
|
||||
(
|
||||
hole_r * math.cos(angle * math.pi / 180),
|
||||
hole_r * math.sin(angle * math.pi / 180),
|
||||
)
|
||||
for angle in [-45, 0, 45, 180 - 45, 180, 180 + 45]
|
||||
]
|
||||
n = n.workplaneFromTagged("nut_face").pushPoints(hole_pts).hole(4.8)
|
||||
return n
|
||||
|
||||
def nutHoles(self, solid, x):
|
||||
w = self.w.transformed(offset=(0, x, 0), rotate=(90, 0, 0))
|
||||
hole_r = 32 / 2
|
||||
hole_pts = [
|
||||
(hole_r*math.cos(angle*math.pi/180),
|
||||
hole_r*math.sin(angle*math.pi/180)) for angle in
|
||||
[-45, 0, 45, 180-45, 180, 180+45]]
|
||||
solid = (solid.copyWorkplane(w)
|
||||
.pushPoints(hole_pts)
|
||||
.hole(4.8))
|
||||
(
|
||||
hole_r * math.cos(angle * math.pi / 180),
|
||||
hole_r * math.sin(angle * math.pi / 180),
|
||||
)
|
||||
for angle in [-45, 0, 45, 180 - 45, 180, 180 + 45]
|
||||
]
|
||||
solid = solid.copyWorkplane(w).pushPoints(hole_pts).hole(4.8)
|
||||
return solid
|
||||
|
||||
def fixedBearing(self):
|
||||
|
@ -89,18 +94,19 @@ class SFU1204:
|
|||
X = 6.6
|
||||
Y = 10.8
|
||||
Z = 1.5
|
||||
w = self.w.transformed(offset=(0, 39+15-L, 0), rotate=(-90, 0, 0))
|
||||
w2 = w.transformed(offset=(0, (H-H1)/2, 0))
|
||||
w = self.w.transformed(offset=(0, 39 + 15, 0), rotate=(-90, 180, 0))
|
||||
w2 = w.transformed(offset=(0, h - H1 / 2, 0))
|
||||
w3 = w.transformed(offset=(0, E / 2, 0))
|
||||
|
||||
bearing = (w
|
||||
.rect(B1, B1)
|
||||
bearing = (
|
||||
w.rect(B1, B1)
|
||||
.extrude(L1 + L)
|
||||
.copyWorkplane(w2)
|
||||
.rect(B, H1)
|
||||
.extrude(L)
|
||||
.copyWorkplane(w.transformed(rotate=(180, 0, 0)))
|
||||
.hole(d1)
|
||||
.copyWorkplane(w2.transformed(rotate=(180, 0, 0)))
|
||||
.copyWorkplane(w3.transformed(rotate=(180, 0, 0)))
|
||||
.rect(P, E, forConstruction=True)
|
||||
.vertices()
|
||||
.hole(d2)
|
||||
|
@ -130,12 +136,9 @@ class SFU1204:
|
|||
Y = 10.8
|
||||
Z = 1.5
|
||||
|
||||
w = self.w.transformed(offset=(0, 39+15-L, -(H-H1)/2), rotate=(-90, 0, 0))
|
||||
return (solid
|
||||
.copyWorkplane(w)
|
||||
.rect(P, E, forConstruction=True)
|
||||
.vertices()
|
||||
.hole(d2)
|
||||
w = self.w.transformed(offset=(0, 39 + 15, -E / 2), rotate=(-90, 0, 0))
|
||||
return (
|
||||
solid.copyWorkplane(w).rect(P, E, forConstruction=True).vertices().hole(d2)
|
||||
)
|
||||
|
||||
def floatingBearing(self):
|
||||
|
@ -154,24 +157,33 @@ class SFU1204:
|
|||
Y = 10.8
|
||||
Z = 1.5
|
||||
|
||||
w = self.w.transformed(offset=(0, self.len-10, 0), rotate=(-90, 0, 0))
|
||||
b = (w
|
||||
.rect(B1, B1)
|
||||
w = self.w.transformed(
|
||||
offset=(0, self.len - 10 + 7 / 2 - L / 2, 0), rotate=(-90, 0, 0)
|
||||
)
|
||||
b = (
|
||||
w.rect(B1, B1)
|
||||
.extrude(L)
|
||||
.faces(">z")
|
||||
.copyWorkplane(w.transformed(offset=(0, 0, L), rotate=(0, 0, 180)))
|
||||
.workplane()
|
||||
.tag("floating_far_end")
|
||||
.copyWorkplane(w)
|
||||
.center(0, (H-H1)/2)
|
||||
.center(0, h - H1 / 2)
|
||||
.rect(B, H1)
|
||||
.extrude(L)
|
||||
.workplaneFromTagged("floating_far_end")
|
||||
.hole(d1)
|
||||
.workplaneFromTagged("floating_far_end")
|
||||
.center(0, -(H-H1)/2)
|
||||
.center(0, -E / 2)
|
||||
.rect(P, E, forConstruction=True)
|
||||
.vertices()
|
||||
.hole(d2)
|
||||
.copyWorkplane(w)
|
||||
.circle(30 / 2)
|
||||
.extrude(L / 2 - 7 / 2, combine="s")
|
||||
.workplaneFromTagged("floating_far_end")
|
||||
.transformed(rotate=(180, 0, 0))
|
||||
.circle(30 / 2)
|
||||
.extrude(L / 2 - 7 / 2, combine="s")
|
||||
)
|
||||
return b
|
||||
|
||||
|
@ -192,15 +204,16 @@ class SFU1204:
|
|||
Z = 1.5
|
||||
|
||||
w = self.w.transformed(offset=(0, self.len - 10 + L, 0), rotate=(90, 0, 0))
|
||||
solid = (solid
|
||||
.copyWorkplane(w)
|
||||
.center(0, -(H-H1)/2)
|
||||
solid = (
|
||||
solid.copyWorkplane(w)
|
||||
.center(0, -E / 2)
|
||||
.rect(P, E, forConstruction=True)
|
||||
.vertices()
|
||||
.hole(d2)
|
||||
)
|
||||
return solid
|
||||
|
||||
|
||||
# it's oriented along the y axis of the given base plane
|
||||
class HGR20:
|
||||
def __init__(self, base, l):
|
||||
|
@ -213,10 +226,12 @@ class HGR20:
|
|||
while x < self.l + 1e-6:
|
||||
pts.append((x - self.l / 2, 0))
|
||||
x += 60
|
||||
w = (w.copyWorkplane(self.base)
|
||||
w = (
|
||||
w.copyWorkplane(self.base)
|
||||
.transformed(offset=(0, 0, 17))
|
||||
.pushPoints(pts)
|
||||
.hole(5))
|
||||
.hole(5)
|
||||
)
|
||||
return w
|
||||
|
||||
def rail_sketch(s=None):
|
||||
|
@ -243,7 +258,7 @@ class HGR20:
|
|||
(31, 186 - 6 - 31, 316 - 6 - 1),
|
||||
(143 + 6, 316 - 6),
|
||||
(143, 316),
|
||||
(0, 316)
|
||||
(0, 316),
|
||||
]
|
||||
scale = (10 / 186 * 17 / 316) ** 0.5
|
||||
scaled_profile = [tuple((scale * v for v in vals)) for vals in hgr_profile]
|
||||
|
@ -277,10 +292,9 @@ class HGR20:
|
|||
pts.append((x - self.l / 2, 0))
|
||||
x += 60
|
||||
# print("points", pts)
|
||||
w = (w.copyWorkplane(xy)
|
||||
.transformed(offset=(0,0,17))
|
||||
.pushPoints(pts)
|
||||
.hole(5)) # TODO replace with counterbore and get proper diameter
|
||||
w = (
|
||||
w.copyWorkplane(xy).transformed(offset=(0, 0, 17)).pushPoints(pts).hole(5)
|
||||
) # TODO replace with counterbore and get proper diameter
|
||||
return w
|
||||
|
||||
W = 44
|
||||
|
@ -307,8 +321,8 @@ class HGR20:
|
|||
w = xy.transformed((90, 90, 0), (-self.l / 2 + x, 0, 0)).tag("endplane")
|
||||
# TODO
|
||||
|
||||
|
||||
s = (cq.Sketch()
|
||||
s = (
|
||||
cq.Sketch()
|
||||
.segment((W / 2, H1), (W / 2, H))
|
||||
.segment((-W / 2, H))
|
||||
.segment((-W / 2, H1))
|
||||
|
@ -316,7 +330,8 @@ class HGR20:
|
|||
.assemble()
|
||||
)
|
||||
s = s.face(HGR20.rail_sketch().assemble(), mode="s")
|
||||
s2 = (cq.Sketch()
|
||||
s2 = (
|
||||
cq.Sketch()
|
||||
.segment((W / 2, H1), (W / 2, H - 3))
|
||||
.segment((-W / 2, H - 3))
|
||||
.segment((-W / 2, H1))
|
||||
|
@ -326,16 +341,20 @@ class HGR20:
|
|||
s2 = s2.face(HGR20.rail_sketch().assemble(), mode="s")
|
||||
|
||||
pts = []
|
||||
|
||||
def savePointsF(l, p):
|
||||
l.append(p)
|
||||
return p
|
||||
|
||||
# origin = w.workplane().plane.toWorldCoords(cq.Vector(0, 0, 0))
|
||||
# norm = w.workplane().plane.toWorldCoords(cq.Vector(0, 1, 0))
|
||||
# norm = norm - origin
|
||||
# print(norm)
|
||||
# FINALLY GOT THIS WORKING
|
||||
w = (w.transformed((0, 0, 0), (0, 0, L/2-L1/2))
|
||||
.placeSketch(s).extrude(L1)
|
||||
w = (
|
||||
w.transformed((0, 0, 0), (0, 0, L / 2 - L1 / 2))
|
||||
.placeSketch(s)
|
||||
.extrude(L1)
|
||||
.workplaneFromTagged("endplane")
|
||||
.placeSketch(s2)
|
||||
.extrude(L)
|
||||
|
@ -362,14 +381,16 @@ class HGR20:
|
|||
l = 5 # M5x6
|
||||
T = 6
|
||||
xy = cq.Workplane().copyWorkplane(self.base).transformed(offset=(0, 0, H))
|
||||
holes = (xy.transformed((0, 0, 0), (-self.l/2+L/2 + x, 0, 0))
|
||||
holes = (
|
||||
xy.transformed((0, 0, 0), (-self.l / 2 + L / 2 + x, 0, 0))
|
||||
.rect(C, B)
|
||||
.vertices()
|
||||
.cylinder(1000, l / 2)
|
||||
)
|
||||
w = (w.cut(holes))
|
||||
w = w.cut(holes)
|
||||
return w
|
||||
|
||||
|
||||
class Plate:
|
||||
# TODO add standard thicknesses here
|
||||
pass
|
||||
|
@ -378,16 +399,16 @@ class Plate:
|
|||
def inch(x):
|
||||
return 25.4 * x
|
||||
|
||||
|
||||
def tubing(l, x, y, w, workplane):
|
||||
return (workplane
|
||||
.placeSketch(cq.Sketch()
|
||||
.rect(x, y)
|
||||
.rect(x - 2*w, y-2*w, mode='s'))
|
||||
.extrude(l))
|
||||
return workplane.placeSketch(
|
||||
cq.Sketch().rect(x, y).rect(x - 2 * w, y - 2 * w, mode="s")
|
||||
).extrude(l)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plate = (cq.Workplane("XY")
|
||||
plate = (
|
||||
cq.Workplane("XY")
|
||||
.rect(200, 200)
|
||||
.extrude(10)
|
||||
.faces(">Z")
|
||||
|
@ -400,7 +421,8 @@ if __name__ == "__main__":
|
|||
plate2 = hgr20.holes(plate)
|
||||
hgrtest = hgr20.rail()
|
||||
carriage = hgr20.carriage(0)
|
||||
plate3 = (cq.Workplane("XY")
|
||||
plate3 = (
|
||||
cq.Workplane("XY")
|
||||
.copyWorkplane(carriage.workplaneFromTagged("mountingholes"))
|
||||
.rect(200, 200)
|
||||
.extrude(5)
|
||||
|
@ -418,7 +440,8 @@ if __name__ == "__main__":
|
|||
|
||||
show_object(ball_screw.ballscrew())
|
||||
show_object(ball_screw.nut(200))
|
||||
nut_holder = (cq.Workplane("XZ")
|
||||
nut_holder = (
|
||||
cq.Workplane("XZ")
|
||||
.transformed(offset=(0, 0, -200 - 50))
|
||||
.rect(40, 30)
|
||||
.extrude(50)
|
||||
|
@ -429,7 +452,8 @@ if __name__ == "__main__":
|
|||
fixed = ball_screw.fixedBearing()
|
||||
show_object(nut_holder)
|
||||
show_object(fixed)
|
||||
bearing_holder = (cq.Workplane("XZ")
|
||||
bearing_holder = (
|
||||
cq.Workplane("XZ")
|
||||
.transformed(offset=(0, 0, 0))
|
||||
.rect(60, 80)
|
||||
.extrude(20)
|
||||
|
@ -440,7 +464,8 @@ if __name__ == "__main__":
|
|||
show_object(bearing_holder)
|
||||
bearing2 = ball_screw.floatingBearing()
|
||||
show_object(bearing2)
|
||||
bearing_holder2 = (cq.Workplane("XZ")
|
||||
bearing_holder2 = (
|
||||
cq.Workplane("XZ")
|
||||
.transformed(offset=(0, 0, -540))
|
||||
.rect(60, 80)
|
||||
.extrude(20)
|
||||
|
@ -451,3 +476,4 @@ if __name__ == "__main__":
|
|||
show_object(bearing_holder2)
|
||||
|
||||
# show_object(cq.Workplane().placeSketch(HGR20.rail_sketch().assemble()).extrude(10))
|
||||
|
||||
|
|
Loading…
Reference in New Issue