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