0% found this document useful (0 votes)
197 views3 pages

Varmain Code

The document defines a Python function called EXPJOINT1 that generates a 3D model of an expansion joint with bellows. The function takes in parameters like pipe diameters, bellow thickness, number of bolts, and bolt size. It creates cylinders and torus shapes to model the flanges and bellows. If bolts are specified, it adds plates and cylinders to model the bolted connection between the flanges.

Uploaded by

jignesh chauhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views3 pages

Varmain Code

The document defines a Python function called EXPJOINT1 that generates a 3D model of an expansion joint with bellows. The function takes in parameters like pipe diameters, bellow thickness, number of bolts, and bolt size. It creates cylinders and torus shapes to model the flanges and bellows. If bolts are specified, it adds plates and cylinders to model the bolted connection between the flanges.

Uploaded by

jignesh chauhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

from varmain.

primitiv import *
from varmain.custom import *

@activate(Group="Sleeve", TooltipShort="Expansion Joint", TooltipLong="Expansion Joint with


Bellows", LengthUnit="in", Ports=2)
@group("MainDimensions")
@param(D=LENGTH, TooltipShort="Pipe OD")
@param(D1=LENGTH, TooltipShort="Flange OD")
@param(D31=LENGTH, TooltipShort="Bellows OD")
@param(L=LENGTH, TooltipLong="Length of the ExpansionJoint")
@param(L31=LENGTH, TooltipShort="Flange Thickness")
@param(T=LENGTH, TooltipShort="Bellows thickness")
@param(B=LENGTH, TooltipShort="Number of Bolts")
@param(B1=LENGTH, TooltipShort="Bolt Size")
@param(B2=LENGTH, TooltipShort="Bolt Length (greater than L)")
@param(OF=LENGTH0)
@group(Name="meaningless enum")
@param(K=ENUM)
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")

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

You might also like