Varmain Code
Varmain Code
primitiv import *
from varmain.custom import *
def EXPJOINT1(s, D=4.5, D31=5.5,D1 = 9.0, B=4, B1=0.75, B2=9.5, L=9.0, L31=0.25, T=0.5, K=1, OF=0,
**kw ):
NumOfBellow=round(((L - (2*L31))/ T)/2)-1
#set a default hole size
fhole = .95*D
#create a hole in the flange
if OF > 0:
fhole = (D-OF)
#create our first flange
Flange1=CYLINDER(s,R=D1/2, H=L31,O=0).rotateY(90)
bellowlength = (T*2*NumOfBellow)-1
nb = 0
#overall length - belows length / 2 plus 1/4 the width of the bellow
offset= ((L - bellowlength - (2*L31))/2)+L31
expBody = CYLINDER(s,R=D31/2,H=L-L31,O=D).rotateY(90).translate((L31,0,0))
#union the first flange and main body
Flange1.uniteWith(expBody)
expBody.erase()
while (nb < NumOfBellow):
#create and offset our torus
b=TORUS(s,R1=D31/2,R2=T/2).rotateY(90).translate((offset,0,0))
#increment our offset distance
offset = offset + T*2
#union as we go
Flange1.uniteWith(b)
b.erase()
nb = nb +1
#create our end flange and offset it
Flange2=CYLINDER(s,R=D1/2, H=L31,O=0).rotateY(90).translate((L - L31,0,0))
Flange1.uniteWith(Flange2)
Flange2.erase()
#see if we need to create bolts, if there is a bolt cound and it's greater than 0
if B > 1 and B1 > 0 and B2 > L:
anglesplit = 360/B
startangle = 0
if B%2!=0:
startangle = anglesplit/2
intbolt=0
incangle=startangle
platewidth=3*B1
platelength=4*B1
plateheight= 0.75*L31
#make the bolts the length of the object + 2 flange thickness
boltlength = L + 4*L31
#calculate our offsets
#plate on flg one offset
pof1 = (L31 - plateheight/2,D1/2+platewidth/2,0)
#translate the bolts
bof1 = (-(B2-L),D1/2+platewidth/2,0)
#translate the second plate
pof2 = (L - (L31 - plateheight/2),D1/2+platewidth/2,0)
#create a cylinder to subtract for the opening
boreCy = CYLINDER(s,R=fhole/2, H=L,O=0).rotateY(90)
Flange1.subtractFrom(boreCy)
boreCy.erase()
while (intbolt < B):
#create a plate for the bolt, rotate it, and then move it to the edge and back to face of flange 1
p=
BOX(s,L=platewidth,W=platelength,H=plateheight).rotateX(90).translate(pof1).rotateX(incangle)
#unite with flange 1 so we have a single body
Flange1.uniteWith(p)
p.erase()
#create the bolt
b = CYLINDER(s, R=B1/2, H=boltlength,O=0).rotateY(90).translate(bof1).rotateX(incangle)
#join the flange and bolt
Flange1.uniteWith(b)
b.erase()
#create our plate on flange 2
p2 =
BOX(s,L=platewidth,W=platelength,H=plateheight).rotateX(90).translate(pof2).rotateX(incangle)
#merge the last plate
Flange1.uniteWith(p2)
p2.erase()
incangle = incangle + anglesplit
intbolt = intbolt + 1
return