home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 March
/
Chip_1998-03_cd.bin
/
tema
/
MINICAD
/
MC7DEMO
/
MINICAD.1
/
BEARINGS.MPC
< prev
next >
Wrap
Text File
|
1997-04-24
|
59KB
|
3,138 lines
Procedure Bearings;
{
⌐1997, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure draws various types of bearings.
}
LABEL 99;
VAR
Type : INTEGER;
Abort : BOOLEAN;
Procedure MainDialog;
{
This procedure defines the main dialog box.
}
VAR
Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2,py3,py4 : INTEGER;
Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
VAR
scrx1,scry1,scrx2,scry2:INTEGER;
BEGIN
GetScreen(scrx1,scry1,scrx2,scry2);
x1:=((scrx1+scrx2) div 2)-(Width div 2);
x2:=x1+Width;
END;
Procedure LocateButtons(DialogType,scnh,scnw : INTEGER);
{
This procedure locates the 'OK' and 'Cancel' buttons.
}
VAR
v1,v2,v3,v4 : INTEGER;
Mac : BOOLEAN;
Procedure Swap(VAR m1,m2,m3,m4 : INTEGER);
VAR
Temp : INTEGER;
BEGIN
Temp:=m1;
m1:=m3;
m3:=Temp;
Temp:=m2;
m2:=m4;
m4:=Temp;
END; {of Swap}
BEGIN
Mac:=FALSE;
GetVersion(v1,v2,v3,v4);
IF v4 = 1 THEN Mac:=TRUE;
IF DialogType = 1 THEN
BEGIN
px1:=(scnw DIV 2) - 80;
px2:=(scnw DIV 2) - 10;
px3:=(scnw DIV 2) + 10;
px4:=(scnw DIV 2) + 80;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE IF DialogType = 2 THEN
BEGIN
px1:=scnw - 180;
px2:=scnw - 110;
px3:=scnw - 90;
px4:=scnw - 20;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE
BEGIN
px1:=scnw - 90;
px2:=scnw - 20;
px3:=px1;
px4:=px2;
py1:=scnh -70;
py2:=scnh - 50;
py3:=scnh - 40;
py4:=scnh - 20;
IF Mac THEN SWAP(py1,py2,py3,py4);
END;
END; {of Locate Buttons}
Procedure MakeDialog6;
CONST
y1=100;
scnw = 250;
scnh = 200;
DialogType = 1;
VAR
h : INTEGER;
BEGIN
AlignScr(scnw,x1,x2);
y2:=y1+scnh;
LocateButtons(DialogType,scnh,scnw);
BeginDialog(6,1,x1,y1,x2,y2);
AddButton('OK',1,1,px1,py1,px2,py2);
AddButton('Cancel',2,1,px3,py3,px4,py4);
h:=-30;
AddField('Type of Bearing:',4,1,20,39+h,195,55+h);
AddButton('Ball Bearing',5,3,20,65+h,220,80+h);
AddButton('Cylindrical Roller Bearing',6,3,20,85+h,220,100+h);
AddButton('Tapered Roller Bearing',7,3,20,105+h,220,120+h);
AddButton('Thrust Bearing',8,3,20,125+h,220,140+h);
{AddButton('Needle Bearing',9,3,20,145+h,220,160+h);}
EndDialog;
END;
BEGIN
MakeDialog6;
END;
Procedure GetInfo1;
{
This procedure displays the main dialog box and retrieves the information.
}
VAR
Item:INTEGER;
RFlag : ARRAY[1..2] OF INTEGER;
Done:BOOLEAN;
Procedure SetRButton(i,Item : INTEGER);
BEGIN
IF RFlag[i] <> Item THEN BEGIN
SetItem(RFlag[i],FALSE);
SetItem(Item,TRUE);
RFlag[i]:=Item;
END;
END;
BEGIN
Done:=FALSE;
Abort:=FALSE;
Type:=1;
RFlag[1]:=5;
GetDialog(6);
SetTitle('Bearings');
SetItem(RFlag[1],TRUE);
REPEAT
DialogEvent(Item);
IF Item=1 THEN
Done:=TRUE;
IF Item=2 THEN
BEGIN
Done:=TRUE;
Abort:=TRUE;
END;
IF (Item >= 4) AND (Item <= 8) THEN BEGIN
SetRButton(1,Item);
Type:=Item-4;
END;
UNTIL DONE;
ClrDialog;
END;
Procedure BallBearing;
{
⌐1997, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure draws the front or side view of ball bearings.
}
LABEL 20,30,40,99;
CONST
BFW=0.75; {Factor used to determine ball diameter. Based on the width of the bearing.}
BFT=2/3; {Factor used to determine ball diameter. Based on the thickness - (OD - ID)/2.}
RF=0.1; {Factor used to determine filet radius.}
TF=0.25; {Factor used to determine thickness of inner and outer rings.}
SF=0.75; {Factor used to calculate number of balls.}
CLF=0.3333; {Factor used to calculate length of centerline.}
ACF=0.75; {Factor used to determine configuration of outer race}
VAR
ID,OD,W,t,a,b,BD,rc : REAL;
x0,y0,x1,y1,dy,dy1,dy2,dy3,dy4,dy5,SW,CL,Lgth : REAL;
r1,r2,r3,br,Theta1,Theta2,Phi,DeltaPhi,s : REAL;
Type,View,NBalls,n : INTEGER;
Abort,ShowSection,Inch : BOOLEAN;
UPI : REAL;
Fmt : INTEGER;
UM,UM2 : STRING;
UName,DA : LONGINT;
Procedure BearingDialog;
{
This procedure creates the dialog box.
}
VAR
Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2,py3,py4 : INTEGER;
Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
VAR
scrx1,scry1,scrx2,scry2:INTEGER;
BEGIN
GetScreen(scrx1,scry1,scrx2,scry2);
x1:=((scrx1+scrx2) div 2)-(Width div 2);
x2:=x1+Width;
END;
Procedure LocateButtons(DialogType,scnh,scnw : INTEGER);
{
This procedure locates the 'OK' and 'Cancel' buttons.
}
VAR
v1,v2,v3,v4 : INTEGER;
Mac : BOOLEAN;
Procedure Swap(VAR m1,m2,m3,m4 : INTEGER);
VAR
Temp : INTEGER;
BEGIN
Temp:=m1;
m1:=m3;
m3:=Temp;
Temp:=m2;
m2:=m4;
m4:=Temp;
END; {of Swap}
BEGIN
Mac:=FALSE;
GetVersion(v1,v2,v3,v4);
IF v4 = 1 THEN Mac:=TRUE;
IF DialogType = 1 THEN
BEGIN
px1:=(scnw DIV 2) - 80;
px2:=(scnw DIV 2) - 10;
px3:=(scnw DIV 2) + 10;
px4:=(scnw DIV 2) + 80;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE IF DialogType = 2 THEN
BEGIN
px1:=scnw - 180;
px2:=scnw - 110;
px3:=scnw - 90;
px4:=scnw - 20;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE
BEGIN
px1:=scnw - 90;
px2:=scnw - 20;
px3:=px1;
px4:=px2;
py1:=scnh -70;
py2:=scnh - 50;
py3:=scnh - 40;
py4:=scnh - 20;
IF Mac THEN SWAP(py1,py2,py3,py4);
END;
END; {of Locate Buttons}
Procedure MakeDialog;
{
This procedure defines the dialog box.
}
CONST
y1=100;
scnh=270;
scnw=360;
DialogType = 2;
VAR
h : INTEGER;
BEGIN
AlignScr(scnw,x1,x2);
y2:=y1+scnh;
LocateButtons(DialogType,scnh,scnw);
BeginDialog(1,1,x1,y1,x2,y2);
AddButton('OK',1,1,px1,py1,px2,py2);
AddButton('Cancel',2,1,px3,py3,px4,py4);
h:=35;
AddField('Inside Diameter:',4,1,20,164-h,145,180-h);
AddField('',5,2,150,165-h,225,180-h);
AddField('in',25,1,233,164-h,265,180-h);
AddField('Outside Diameter:',6,1,20,189-h,145,205-h);
AddField('',7,2,150,190-h,225,205-h);
AddField('in',26,1,233,189-h,265,205-h);
AddField('Width:',8,1,20,214-h,145,230-h);
AddField('',9,2,150,215-h,225,230-h);
AddField('in',27,1,233,214-h,265,230-h);
AddField('View:',10,1,270,134-h,315,150-h);
AddButton('Section',11,3,270,155-h,350,170-h);
AddButton('Front',12,3,270,175-h,325,190-h);
AddField('Type:',13,1,20,44-h,120,60-h);
AddButton('Single Row Radial',14,3,20,65-h,160,80-h);
AddButton('SRR, Self-Contained',15,3,20,85-h,175,100-h);
AddButton('Single Row Angular',16,3,20,105-h,175,120-h);
AddButton('Double Row Radial',17,3,190,65-h,335,80-h);
AddButton('DRR, Self-Contained',18,3,190,85-h,340,100-h);
AddButton('Double Row Angular',19,3,190,105-h,340,120-h);
AddButton('Show Section Lines',20,2,20,245-h,170,260-h);
AddField('Series:',22,1,20,134-h,65,150-h);
AddButton('Inch',23,3,70,135-h,120,150-h);
AddButton('Metric (mm)',24,3,125,135-h,225,150-h);
EndDialog;
END;
BEGIN
MakeDialog;
END;
Procedure GetInfo;
{
This procedure displays the dialog box and retrieves the information.
}
LABEL 10,20;
VAR
Item:integer;
RFlag : ARRAY[1..3] OF INTEGER;
Done:boolean;
Procedure SetRButton(i,Item : INTEGER);
BEGIN
IF RFlag[i] <> Item THEN
BEGIN
SetItem(RFlag[i],FALSE);
SetItem(Item,TRUE);
RFlag[i]:=Item;
END;
END;
BEGIN
Done:=FALSE;
Abort:=FALSE;
View:=1;
Type:=1;
ShowSection:=TRUE;
Inch:=TRUE;
ID:=1.0000;
OD:=2.0000;
W:=0.5000;
RFlag[1]:=14;
RFlag[2]:=11;
RFlag[3]:=23;
GetDialog(1);
SetTitle('Ball Bearings');
SetItem(RFlag[1],TRUE);
SetItem(RFlag[2],TRUE);
SetItem(RFlag[3],TRUE);
SetItem(20,ShowSection);
SetField(5,Num2Str(4,ID));
SetField(7,Num2Str(4,OD));
SetField(9,Num2Str(4,W));
10:SelField(5);
REPEAT
DialogEvent(Item);
IF Item=1 THEN
Done:=TRUE;
IF Item=2 THEN
BEGIN
Done:=TRUE;
Abort:=TRUE;
END;
IF (Item = 11) OR (Item = 12) THEN
BEGIN
SetRButton(2,Item);
View:=Item-10;
END;
IF (Item > 13) AND (Item < 20) THEN
BEGIN
SetRButton(1,Item);
Type:=Item-13;
END;
IF Item=20 THEN
BEGIN
ShowSection:=NOT ShowSection;
SetItem(Item,ShowSection);
END;
IF Item = 23 THEN
BEGIN
IF RFlag[3] <> Item THEN
BEGIN
SetRButton(3,Item);
SetField(25,'in');
SetField(26,'in');
SetField(27,'in');
SelField(5);
Inch:=TRUE;
END;
END;
IF Item = 24 THEN
BEGIN
IF RFlag[3] <> Item THEN BEGIN
SetRButton(3,Item);
SetField(25,'mm');
SetField(26,'mm');
SetField(27,'mm');
SelField(5);
Inch:=FALSE;
END;
END;
UNTIL DONE;
IF Abort THEN GOTO 20;
ID:=Str2Num(GetField(5));
OD:=Str2Num(GetField(7));
W:=Str2Num(GetField(9));
IF ID < OD THEN GOTO 20;
SysBeep;
AlrtDialog('ID must be less than OD!');
Done:=FALSE;
GOTO 10;
20:ClrDialog;
END;
Procedure DrawCL1(CL:REAL);
{
This procedure draws a horizontal and vertical centerline through the ball.
}
BEGIN
Move(CL/2,0);
Line(-CL,0);
Move(CL/2,CL/2);
Line(0,-CL);
Move(0,CL/2);
END;
Procedure DrawCL2(CL:REAL);
{
This procedure draws a horizontal and angled centerline through the balls on angular contact bearings.
}
BEGIN
Move(CL/2,0);
Line(-CL,0);
Move(0,-CL);
Line(CL,2*CL);
Move(-CL/2,-CL);
END;
Procedure DrawCL3(CL:REAL);
{
This procedure draws a horizontal and angled centerlines through the balls on angular contact bearings.
}
BEGIN
Move(CL/2,0);
Line(-CL,0);
Move(0,CL);
Line(CL,-2*CL);
Move(-CL/2,CL);
END;
{
Main program.
}
BEGIN
PushAttrs;
{
Display dialog box and get information.
}
BearingDialog;
DSelectAll;
SetCursor(ArrowC);
GetInfo;
IF Abort THEN GOTO 99;
DSelectAll;
{
Get units per inch and adjust parameters.
}
GetUnits(UName,DA,Fmt,UPI,UM,UM2);
IF Inch THEN
BEGIN
ID:=ID*UPI;
OD:=OD*UPI;
W:=W*UPI;
END ELSE
BEGIN
ID:=ID*UPI/25.4;
OD:=OD*UPI/25.4;
W:=W*UPI/25.4;
END;
{
Get location of bearing.
}
GetPt(x0,y0);
{
Define variables.
}
{
Determine ball diameter (BD).
}
t:=(OD-ID)/2;
BD:=BFW*W;
IF (TYPE=4) OR (TYPE=5) OR (TYPE=6) THEN
BD:=BD/2;
IF BFT*t < BD THEN
BD:=BFT*t;
{
Determine length of centerline (CL).
}
CL:=CLF*BD;
{
Determine filet radius (rc).
}
rc:=RF*t;
IF RF*W < rc THEN
rc:=RF*W;
{
Determine thickness of inner and outer rings (a).
}
a:=TF*bd;
{
Determine various other variables used to draw bearing.
}
b:=t/2-a;
r1:=OD/2-b;
r2:=ID/2+b;
r3:=(OD+ID)/4;
br:=BD/2;
dy1:=t/2-br;
dy2:=b-dy1;
dy3:=ACF*dy1;
dy4:=(1-ACF)*dy1;
dy5:=b-dy3;
IF Type=5 THEN
dy:=dy2
ELSE IF Type=6 THEN
dy:=dy5
ELSE
dy:=0;
FillPat(1);
IF View=2 THEN GOTO 40;
{
Draw side view.
}
FillPat(1);
Absolute;
MoveTo(x0,y0-(OD/2-rc));
Relative;
RECT(0,0,W,(OD-2*rc));
{
Draw inner race.
}
Absolute;
MoveTo(x0,y0+r2);
Relative;
ClosePoly;
IF ShowSection THEN
FillPat(12);
BeginPoly;
ArcTo(0,-b,rc);
ArcTo(W,0,rc);
LineTo(0,b);
IF Type=6 THEN
BEGIN
LineTo(-W/4,0);
LineTo(0,-dy2);
LineTo(-W/2,0);
LineTo(0,dy2);
LineTo(-W/4,0);
END ELSE
LineTo(-W,0);
EndPoly;
MoveTo(0,-2*r2);
BeginPoly;
ArcTo(0,b,rc);
ArcTo(W,0,rc);
LineTo(0,-b);
IF Type=6 THEN
BEGIN
LineTo(-W/4,0);
LineTo(0,dy2);
LineTo(-W/2,0);
LineTo(0,-dy2);
LineTo(-W/4,0);
END
ELSE
LineTo(-W,0);
EndPoly;
FillPat(1);
{
Draw Outer Race.
}
Absolute;
MoveTo(x0,y0+r1);
Relative;
IF ShowSection THEN
FillPat(24);
BeginPoly;
ArcTo(0,b,rc);
ArcTo(W,0,rc);
IF Type=2 THEN
BEGIN
LineTo(0,-dy1);
LineTo(-w/2,0);
LineTo(0,-dy2);
LineTo(-w/2,0);
END ELSE IF Type=3 THEN
BEGIN
LineTo(0,-dy3);
LineTo(-w/2,-dy4);
LineTo(0,-dy2);
LineTo(-w/2,0);
END ELSE IF Type=5 THEN
BEGIN
LineTo(0,-dy1);
LineTo(-w/4,0);
LineTo(0,-dy2);
LineTo(-w/2,0);
LineTo(0,dy2);
LineTo(-w/4,0);
END ELSE IF Type=6 THEN
BEGIN
LineTo(0,-dy3);
LineTo(-w/4,-dy4);
LineTo(0,-dy2);
LineTo(-w/2,0);
LineTo(0,dy2);
LineTo(-w/4,dy4);
END ELSE
BEGIN
LineTo(0,-b);
LineTo(-W,0);
END;
EndPoly;
MoveTo(0,-(2*r1+dy));
BeginPoly;
ArcTo(0,-b,rc);
ArcTo(W,0,rc);
IF Type=2 THEN
BEGIN
LineTo(0,(t/2-br));
LineTo(-w/2,0);
LineTo(0,dy1);
LineTo(-w/2,0);
END ELSE IF Type=3 THEN
BEGIN
LineTo(0,dy3);
LineTo(-w/2,dy4);
LineTo(0,dy2);
LineTo(-w/2,0);
END ELSE IF Type=5 THEN
BEGIN
LineTo(0,dy1);
LineTo(-w/4,0);
LineTo(0,dy2);
LineTo(-w/2,0);
LineTo(0,-dy2);
LineTo(-w/4,0);
END ELSE IF Type=6 THEN
BEGIN
LineTo(0,dy3);
LineTo(-w/4,dy4);
LineTo(0,dy2);
LineTo(-w/2,0);
LineTo(0,-dy2);
LineTo(-w/4,-dy4);
END ELSE
BEGIN
LineTo(0,b);
LineTo(-W,0);
END;
EndPoly;
{
Draw Balls.
}
FillPat(1);
{
Single Row.
}
IF (Type=1) OR (Type=2) OR (Type=3) THEN
BEGIN
Absolute;
MoveTo(x0+W/2,y0-r3);
Relative;
Oval(-br,br,br,-br);
IF Type=3 THEN
DrawCL2(CL)
ELSE
DrawCL1(CL);
Move(0,2*r3);
Oval(-br,br,br,-br);
IF Type=3 THEN
DrawCL3(CL)
ELSE
DrawCL1(CL);
END
{
Double Row.
}
ELSE BEGIN
Absolute;
MoveTo(x0+w/4,y0+r3);
Relative;
Oval(-br,br,br,-br);
IF Type=6 THEN
DrawCL2(CL)
ELSE
DrawCL1(CL);
Move(W/2,0);
Oval(-br,br,br,-br);
IF Type=6 THEN
DrawCL3(CL)
ELSE
DrawCL1(CL);
Move(0,-2*r3);
Oval(-bd/2,bd/2,bd/2,-bd/2);
IF Type=6 THEN
DrawCL3(CL)
ELSE
DrawCL1(CL);
Move(-W/2,0);
Oval(-br,br,br,-br);
IF Type=6 THEN
DrawCL2(CL)
ELSE
DrawCL1(CL);
END;
GOTO 99;
{
Draw front view.
}
40:s:=SF*BD;
Phi:=2*s/r3;
NBalls:=2*PI/Phi;
DeltaPhi:=360/NBalls;
IF (Type = 5) OR (Type = 6) THEN
r1:=r1+dy2;
Phi:=-DeltaPhi;
Theta1:=Rad2Deg(ArcCos((br^2+r3^2-r2^2)/(2*br*r3)));
Theta2:=Rad2Deg(ArcCos((br^2+r3^2-r1^2)/(2*br*r3)));
FillPat(1);
Absolute;
MoveTo(x0,y0);
Relative;
Arc(-OD/2,OD/2,OD/2,-OD/2,0,360);
IF Type = 6 THEN
Arc(-(OD/2-dy3),(OD/2-dy3),(OD/2-dy3),-(OD/2-dy3),0,360);
Arc(-r1,r1,r1,-r1,0,360);
Arc(-r2,r2,r2,-r2,0,360);
Arc(-ID/2,ID/2,ID/2,-ID/2,0,360);
FOR n:=1 TO NBalls DO
BEGIN
Phi:=Phi+DelTaPhi;
x1:=r3*Sin(Deg2Rad(Phi));
y1:=r3*Cos(Deg2Rad(Phi));
Absolute;
MoveTo(x0+x1,y0+y1);
Relative;
Arc(-br,br,br,-br,(270-Theta2-Phi),(Theta2-Theta1));
Arc(-br,br,br,-br,-(90-Theta1+Phi),(Theta2-Theta1));
END;
99:Group;
PopAttrs;
END;
Procedure RollerBearing;
{
⌐1996, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure draws cylindrical roller bearings.
}
LABEL 10,11,12,15,16,20,25,30,40,98,99;
CONST
maxPoints = 15;
{
The following constants are used to determine the width of roller(s).
}
kwr1 = 0.666667; {Types 1,2,3,4,9}
kwr2 = 0.375; {Types 5,6,7}
kwr3 = 0.33333; {Types 8,10}
{
The following constants are used to determine the roller diameter.
}
kdr1 = 0.6; {Types 1,2,3,5,6,7}
kdr2 = 0.65; {Types 4,8}
kdr3 = 0.5; {Types 9,10}
{
The following constant is used to determine the minimum roller diameter.
}
kMinDr = 0.1;
{
The following constants are used to determine the fillet radius.
}
krft = 0.0625;
krfw = 0.125;
{
The following constant is used to determine shoulder height.
}
ks = 0.75;
{
The following constants are used to determine the spacing between rollers.
}
ksp = 1.25;
ks3 = 0.25;
VAR
ID,OD,W,w1,t,a1,a2,a3,a4,a5,a6,a7,a8 : REAL;
b,c,d,d1,d2,dr,dr2,rc,wr : REAL;
x0,y0,x1,y1,x2,s,s2,s3,s4,s5,tw,f : REAL;
rf,tf,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11 : REAL;
Alpha,Theta,Phi,dPhi : REAL;
x,y,r : ARRAY[1..maxPoints] OF REAL;
i,j,k,m,Type,View,n,nRollers,nPoints : INTEGER;
Abort,ShowSection,Inch : BOOLEAN;
ODS,IDS,WS,DisplayUnits : STRING;
RollerH : HANDLE;
UPI : REAL;
Fmt : INTEGER;
UM,UM2 : STRING;
UName,DA : LONGINT;
Procedure BearingDialog;
{
This procedure defines the dialog box.
}
VAR
Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2,py3,py4 : INTEGER;
Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
VAR
scrx1,scry1,scrx2,scry2:INTEGER;
BEGIN
GetScreen(scrx1,scry1,scrx2,scry2);
x1:=((scrx1+scrx2) div 2)-(Width div 2);
x2:=x1+Width;
END;
Procedure LocateButtons(DialogType,scnh,scnw : INTEGER);
{
This procedure locates the 'OK' and 'Cancel' buttons.
}
VAR
v1,v2,v3,v4 : INTEGER;
Mac : BOOLEAN;
Procedure Swap(VAR m1,m2,m3,m4 : INTEGER);
VAR
Temp : INTEGER;
BEGIN
Temp:=m1;
m1:=m3;
m3:=Temp;
Temp:=m2;
m2:=m4;
m4:=Temp;
END; {of Swap}
BEGIN
Mac:=FALSE;
GetVersion(v1,v2,v3,v4);
IF v4 = 1 THEN Mac:=TRUE;
IF DialogType = 1 THEN
BEGIN
px1:=(scnw DIV 2) - 80;
px2:=(scnw DIV 2) - 10;
px3:=(scnw DIV 2) + 10;
px4:=(scnw DIV 2) + 80;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE IF DialogType = 2 THEN
BEGIN
px1:=scnw - 180;
px2:=scnw - 110;
px3:=scnw - 90;
px4:=scnw - 20;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE
BEGIN
px1:=scnw - 90;
px2:=scnw - 20;
px3:=px1;
px4:=px2;
py1:=scnh -70;
py2:=scnh - 50;
py3:=scnh - 40;
py4:=scnh - 20;
IF Mac THEN SWAP(py1,py2,py3,py4);
END;
END; {of Locate Buttons}
Procedure MakeDialog;
CONST
y1=100;
scnh=320;
scnw=405;
DialogType = 2;
VAR
h,h1 : INTEGER;
BEGIN
AlignScr(scnw,x1,x2);
y2:=y1+scnh;
LocateButtons(DialogType,scnh,scnw);
BeginDialog(1,1,x1,y1,x2,y2);
AddButton('OK',1,1,px1,py1,px2,py2);
AddButton('Cancel',2,1,px3,py3,px4,py4);
h:=35;
AddField('Ring Configuration (Ribs-inner ring/Ribs-outer ring):',55,1,20,44-h,380,60-h);
AddField('Single Row:',29,1,20,64-h,175,80-h);
AddField('Double Row:',30,1,210,64-h,375,80-h);
AddButton('Double/Double',14,3,20,85-h,175,100-h);
AddButton('Double/None',15,3,20,105-h,175,120-h);
AddButton('None/Double',16,3,20,125-h,175,140-h);
AddButton('Self-Aligning Outer Ring',17,3,20,145-h,195,160-h);
AddButton('Self-Aligning Inner Ring',22,3,20,165-h,195,180-h);
AddButton('Double/Double',18,3,210,85-h,375,100-h);
AddButton('Double/None',19,3,210,105-h,375,120-h);
AddButton('None/Double',20,3,210,125-h,375,140-h);
AddButton('Self-Aligning Outer Ring',21,3,210,145-h,395,160-h);
AddButton('Self-Aligning Inner Ring',23,3,210,165-h,395,180-h);
h1:=60-h;
AddField('Series:',35,1,20,134+h1,65,150+h1);
AddButton('Inch',36,3,70,135+h1,120,150+h1);
AddButton('Metric (mm)',37,3,125,135+h1,225,150+h1);
AddField('Inside Diameter:',4,1,20,164+h1,145,180+h1);
AddField('',5,2,150,165+h1,225,180+h1);
AddField('in',25,1,233,164+h1,275,180+h1);
AddField('Outside Diameter:',6,1,20,189+h1,145,205+h1);
AddField('',7,2,150,190+h1,225,205+h1);
AddField('in',26,1,233,189+h1,275,205+h1);
AddField('Width:',8,1,20,214+h1,145,230+h1);
AddField('',9,2,150,215+h1,225,230+h1);
AddField('in',27,1,233,214+h1,275,230+h1);
AddField('View:',10,1,280,134+h1,325,150+h1);
AddButton('Section',11,3,280,155+h1,360,170+h1);
AddButton('Front',12,3,280,175+h1,360,195+h1);
AddButton('Rear',13,3,280,195+h1,360,215+h1);
AddButton('Show Section Lines',28,2,20,245+h1,170,260+h1);
EndDialog;
END;
BEGIN
MakeDialog;
END;
Procedure GetInfo;
{
This procedure displays the dialox box and retrieves the information.
}
LABEL 5,10,20;
VAR
f : REAL;
n,Item : INTEGER;
RFlag : ARRAY[1..3] OF INTEGER;
Done,OK : BOOLEAN;
Procedure SetRButton(i,Item : INTEGER);
BEGIN
IF RFlag[i] <> Item THEN BEGIN
SetItem(RFlag[i],FALSE);
SetItem(Item,TRUE);
RFlag[i]:=Item;
END;
END;
BEGIN
Done:=FALSE;
Abort:=FALSE;
View:=1;
Type:=1;
ShowSection:=TRUE;
Inch:=TRUE;
OD:=2.0000;
ID:=1.0000;
W:=0.5000;
RFlag[1]:=Type+13;
RFlag[2]:=View+10;
RFlag[3]:=36;
GetDialog(1);
SetTitle('Cylindrical Roller Bearings');
SetItem(RFlag[1],TRUE);
SetItem(RFlag[2],TRUE);
SetItem(RFlag[3],TRUE);
SetItem(28,ShowSection);
SetField(5,Num2Str(4,ID));
SetField(7,Num2Str(4,OD));
SetField(9,Num2Str(4,W));
10:SelField(5);
REPEAT
DialogEvent(Item);
IF Item=1 THEN
Done:=TRUE;
IF Item=2 THEN
BEGIN
Done:=TRUE;
Abort:=TRUE;
END;
IF (Item>=11) AND (Item<=13) THEN
BEGIN
SetRButton(2,Item);
View:=Item-10;
END;
IF (Item>=14) AND (Item<=23) THEN
BEGIN
SetRButton(1,Item);
Type:=Item-13;
END;
IF Item=28 THEN
BEGIN
SetItem(Item,NOT ShowSection);
ShowSection:=NOT ShowSection;
END;
IF Item=36 THEN
BEGIN
IF RFlag[3]<>Item THEN
BEGIN
SetRButton(3,Item);
Inch:=TRUE;
SetField(25,'in');
SetField(26,'in');
SetField(27,'in');
END;
END;
IF Item=37 THEN
BEGIN
IF RFlag[3]<>Item THEN
BEGIN
SetRButton(3,Item);
Inch:=FALSE;
SetField(25,'mm');
SetField(26,'mm');
SetField(27,'mm');
END;
END;
UNTIL DONE;
IF Abort THEN GOTO 20;
OK:=ValidNumStr(GetField(5),ID);
OK:=ValidNumStr(GetField(7),OD);
OK:=ValidNumStr(GetField(9),W);
IF ID < OD THEN GOTO 20;
SysBeep;
AlrtDialog('ID must be less than OD!');
Done:=FALSE;
GOTO 10;
20:ClrDialog;
END;
Procedure DrawWasher(x0,y0,OD,ID:REAL);
VAR
r1,r2 : REAL;
x,y,r : ARRAY[1..13] OF REAL;
n : INTEGER;
BEGIN
r1:=OD/2;
r2:=ID/2;
x[1]:=0; y[1]:=r1; r[1]:=0;
x[2]:=r1; y[2]:=r1; r[2]:=r1;
x[3]:=r1; y[3]:=-r1; r[3]:=r1;
x[4]:=-r1; y[4]:=-r1; r[4]:=r1;
x[5]:=-r1; y[5]:=r1; r[5]:=r1;
x[6]:=0; y[6]:=r1; r[6]:=0;
x[7]:=0; y[7]:=r2; r[7]:=-1;
x[8]:=-r2; y[8]:=r2; r[8]:=r2;
x[9]:=-r2; y[9]:=-r2; r[9]:=r2;
x[10]:=r2; y[10]:=-r2; r[10]:=r2;
x[11]:=r2; y[11]:=r2; r[11]:=r2;
x[12]:=0; y[12]:=r2; r[12]:=0;
x[13]:=0; y[13]:=r1; r[13]:=-1;
Absolute;
MoveTo(x0,y0);
OpenPoly;
BeginPoly;
FOR n:=1 TO 13 DO
BEGIN
x[n]:=x[n]+x0;
y[n]:=y[n]+y0;
IF r[n]<0 THEN
MoveTo(x[n],y[n])
ELSE IF r[n]=0 THEN
LineTo(x[n],y[n])
ELSE
ArcTo(x[n],y[n],r[n]);
END;
EndPoly;
END;
Procedure DrawPoint(x,y,r:REAL);
BEGIN
IF r<0 THEN
CurveThrough(x,y)
ELSE IF r=0 THEN
LineTo(x,y)
ELSE
ArcTo(x,y,r);
END;
Procedure DrawRoller(d1,d2,w:REAL);
BEGIN
FillPat(1);
Relative;
BeginGroup;
IF d1=d2 THEN
Rect(-w/2,d1/2,w/2,-d1/2)
ELSE BEGIN
MoveTo(-w/2,d2/2);
ClosePoly;
BeginPoly;
LineTo(0,0);
CurveThrough(w/2,(d1-d2)/2);
LineTo(w/2,-(d1-d2)/2);
LineTo(0,-d2);
CurveThrough(-w/2,-(d1-d2)/2);
LineTo(-w/2,(d1-d2)/2);
EndPoly;
Move(w/2,d2/2);
END;
IF ShowSection THEN
BEGIN
Move(-w/2,d2/2);
LineTo(w,-d2);
Move(0,d2);
LineTo(-w,-d2);
END;
EndGroup;
END;
{
Main program.
}
BEGIN
PushAttrs;
{
Display dialog box and get information.
}
BearingDialog;
DSelectAll;
SetCursor(ArrowC);
GetInfo;
IF Abort THEN GOTO 99;
{
Get units per inch and adjust sizes accordingly.
}
GetUnits(UName,DA,Fmt,UPI,UM,UM2);
IF Inch THEN
BEGIN
ID:=ID*UPI;
OD:=OD*UPI;
W:=W*UPI;
END ELSE
BEGIN
ID:=ID*UPI/25.4;
OD:=OD*UPI/25.4;
W:=W*UPI/25.4;
END;
{
Calculate variables needed to draw bearing.
}
t:=(OD-ID)/2;
IF (Type=4)OR(Type=8) THEN
dr:=kdr2*t
ELSE IF (Type=9)OR(Type=10) THEN
dr:=kdr3*t
ELSE dr:=kdr1*t;
IF (Type<=4)OR(Type=9) THEN
BEGIN
wr:=kwr1*W;
b:=(W-wr)/2;
END
ELSE IF (Type=8)OR(Type=10) THEN
BEGIN
wr:=kwr3*W;
b:=(W-2*wr)/3;
END ELSE
BEGIN
wr:=kwr2*W;
b:=(W-2*wr)/3;
END;
c:=(t-dr)/2;
rf:=krft*t;
IF krfw*W < rf THEN rf:=krfw*W;
r2:=(ID+t)/2;
IF (Type<=3)OR((Type>=5)AND(Type<=7)) THEN
BEGIN
s:=ks*dr;
a1:=(t-s)/2;
IF (Type=3)OR(Type=7) THEN
r1:=ID/2+c
ELSE r1:=ID/2+a1;
IF (Type=2)OR(Type=6) THEN
r3:=OD/2-c
ELSE r3:=OD/2-a1;
s2:=0;
dr2:=dr;
s3:=(b+wr)/2;
END
ELSE IF Type=4 THEN
BEGIN
10:r4:=r2+dr/2;
IF W > 2*r4 THEN
REPEAT
dr:=0.95*dr;
IF dr<= kMinDr*t THEN GOTO 98;
r4:=r2+dr/2;
UNTIL 2*r4 > W;
c:=(t-dr)/2;
Theta:=ArcSin(W/(2*r4));
r6:=r4*Cos(Theta);
s2:=r4-Sqrt(r4^2 - (wr/2)^2);
dr2:=dr-2*s2;
IF dr2 <= 0 THEN GOTO 98;
s:=ks*dr2;
a1:=(t-s)/2;
a2:=OD/2-r6;
a4:=(t-dr2)/2;
a5:=a1-a4;
r1:=ID/2+a1;
IF (r1>r6) OR (r4>OD/2) THEN
BEGIN
dr:=dr*0.95;
GOTO 10;
END;
END
ELSE IF Type=8 THEN
BEGIN
11:s3:=ks3*W;
r5:=Sqrt(r2^2+s3^2);
r4:=r5+dr/2;
IF W > 2*r4 THEN
REPEAT
dr:=0.95*dr;
IF dr<= kMinDr*t THEN GOTO 98;
s3:=ks3*W;
r5:=Sqrt(r2^2+s3^2);
r4:=r5+dr/2;
UNTIL 2*r4 > W;
c:=(t-dr)/2;
Alpha:=ArcSin(s3/r5);
Theta:=ArcSin(W/(2*r4));
r6:=r4*Cos(Theta);
s2:=r4-Sqrt(r4^2 - (wr/2)^2);
dr2:=dr-2*s2;
IF dr2 <= 0 THEN GOTO 98;
s:=ks*dr2;
a1:=(t-s)/2;
a2:=OD/2-r6;
a4:=(t-dr2)/2;
a5:=a1-a4;
a6:=t/2 - wr*Sin(Alpha)/2 - dr2*Cos(Alpha)/2 + a5;
a3:=a6+Wr*Sin(Alpha);
s4:=s3 + wr*Cos(Alpha)/2 - dr2*Sin(Alpha)/2;
s5:=s3 - wr*Cos(Alpha)/2;
c:=OD/2-r4;
r1:=ID/2+a6;
r7:=r2-wr*Sin(Alpha)/2;
r8:=ID/2+a3;
IF (r1>r6)OR(r4>OD/2) THEN
BEGIN
dr:=dr*0.95;
GOTO 11;
END;
END
ELSE IF (Type = 9) OR (Type = 10) THEN
BEGIN
IF Type=9 THEN W:=2*W;
12:s3:=ks3*W;
r5:=Sqrt(r2^2+s3^2);
r4:=Sqrt((r5-dr/2)^2 + (wr/2)^2);
IF W > 2*r4 THEN
REPEAT
dr:=0.95*dr;
IF dr<= kMinDr*t THEN GOTO 98;
s3:=ks3*W;
r5:=Sqrt(r2^2+s3^2);
r4:=Sqrt((r5-dr/2)^2 + (wr/2)^2);
UNTIL 2*r4 > W;
IF W > 2*r4 THEN
BEGIN
Sysbeep;
AlrtDialog('That configuration is not possible!');
GOTO 99;
END;
s2:=r4-Sqrt(r4^2 - (wr/2)^2);
dr2:=dr-2*s2;
IF dr2 <= 0 THEN GOTO 98;
Alpha:=ArcSin(s3/r5);
Theta:=ArcSin(W/(2*r4));
r1:=r4*Cos(Theta);
a1:=r1-ID/2;
a2:=r4-ID/2;
IF Type=10 THEN
a3:=r4/Cos(Theta)-ID/2
ELSE
a3:=r4-ID/2;
s4:=r4*Sin(Alpha);
a4:=Sqrt(r4^2 - s4^2)-ID/2;
s5:=s3-(wr*Cos(Alpha)/2 + dr*Sin(Alpha)/2);
a5:=Sqrt(r4^2 - (W/2-s5)^2)-ID/2;
r6:=OD/2-a2;
r7:=r2-wr*Sin(Alpha)/2;
a7:=OD/2-Sqrt((r4+dr)^2 - (W/4)^2);
a8:=Sqrt(r4^2 - (W/4)^2) - ID/2;
IF Type=9 THEN
BEGIN
r9:=r7+wr*Sin(Alpha);
r10:=ID/2+a3;
r11:=OD/2-a5;
END;
IF (r1>r6)OR(r4<ID/2)OR(r1<ID/2) THEN
BEGIN
dr:=dr*0.95;
GOTO 12;
END;
END;
{
Get insertion point.
}
GetPt(x0,y0);
IF (View=2) OR (View=3) THEN GOTO 30;
{
Draw Side View
}
{
Draw outer ring.
}
IF (Type=1) OR (Type=3) THEN
BEGIN
nPoints:=8;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a1; r[3]:=0;
x[4]:=W-b; y[4]:=a1; r[4]:=0;
x[5]:=W-b; y[5]:=c; r[5]:=0;
x[6]:=b; y[6]:=c; r[6]:=0;
x[7]:=b; y[7]:=a1; r[7]:=0;
x[8]:=0; y[8]:=a1; r[8]:=0;
END
ELSE IF (Type=2) OR (Type=6) THEN
BEGIN
nPoints:=4;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=c; r[3]:=0;
x[4]:=0; y[4]:=c; r[5]:=0;
END
ELSE IF Type=4 THEN
BEGIN
nPoints:=5;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a2; r[3]:=0;
x[4]:=W/2; y[4]:=c; r[4]:=-1;
x[5]:=0; y[5]:=a2; r[5]:=0;
END
ELSE IF (Type=5) OR (Type=7) THEN
BEGIN
nPoints:=12;
x[1]:=0; y[1]:=0;
x[2]:=W; y[2]:=0;
x[3]:=W; y[3]:=a1;
x[4]:=W-b; y[4]:=a1;
x[5]:=W-b; y[5]:=c;
x[6]:=2*b+wr; y[6]:=c;
x[7]:=2*b+wr; y[7]:=a1;
x[8]:=b+wr; y[8]:=a1;
x[9]:=b+wr; y[9]:=c;
x[10]:=b; y[10]:=c;
x[11]:=b; y[11]:=a1;
x[12]:=0; y[12]:=a1;
r[1]:=rf;
r[2]:=rf;
FOR k:=3 TO 12 DO
r[k]:=0;
END
ELSE IF Type=8 THEN
BEGIN
nPoints:=5;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a2; r[3]:=0;
x[4]:=W/2; y[4]:=c; r[4]:=-1;
x[5]:=0; y[5]:=a2; r[5]:=0;
END
ELSE IF Type=9 THEN
BEGIN
nPoints:=5;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W/2-s5; y[2]:=0; r[2]:=rf;
x[3]:=W/2-s5; y[3]:=a5; r[3]:=0;
x[4]:=W/4; y[4]:=a4; r[4]:=-1;
x[5]:=0; y[5]:=a2; r[5]:=0;
END
ELSE IF Type=10 THEN
BEGIN
nPoints:=8;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a2; r[3]:=0;
x[4]:=W-s4; y[4]:=a4; r[4]:=-1;
x[5]:=W/2+s5; y[5]:=a5; r[5]:=0;
x[6]:=W/2-s5; y[6]:=a5; r[6]:=0;
x[7]:=s4; y[7]:=a4; r[7]:=-1;
x[8]:=0; y[8]:=a2; r[8]:=0;
END;
Absolute;
FillPat(1);
MoveTo(x0,y0+OD/2);
Relative;
ClosePoly;
IF Type=9 THEN w1:=W/2-s5
ELSE w1:=W;
BeginPoly;
ArcTo(0,0,rf);
ArcTo(w1,0,rf);
ArcTo(0,-OD,rf);
ArcTo(-w1,0,rf);
EndPoly;
IF ShowSection THEN FillPat(24)
ELSE FillPat(1);
Absolute;
ClosePoly;
j:=1;
FOR m:=1 TO 2 DO
BEGIN
BeginPoly;
FOR k:=1 TO nPoints DO
BEGIN
x1:=x0+x[k];
y1:=y0-j*(OD/2-y[k]);
DrawPoint(x1,y1,r[k]);
END;
EndPoly;
j:=-1;
END;
{
Draw inner ring.
}
IF Type=9 THEN
BEGIN
nPoints:=6;
x[1]:=0; y[1]:=ID/2+a1; r[1]:=0;
x[2]:=W/4; y[2]:=ID/2+a8; r[2]:=0;
x[3]:=W/2; y[3]:=ID/2+a3; r[3]:=0;
x[4]:=x[3]; y[4]:=-y[3]; r[4]:=0;
x[5]:=x[2]; y[5]:=-y[2]; r[5]:=0;
x[6]:=x[1]; y[6]:=-y[1]; r[6]:=0;
FillPat(1);
Absolute;
ClosePoly;
FillPat(1);
BeginPoly;
FOR k:=1 TO nPoints DO
BEGIN
x1:=x0+x[k];
y1:=y0+y[k];
DrawPoint(x1,y1,r[k]);
END;
EndPoly;
END;
IF (Type=1) OR (Type=2) THEN
BEGIN
nPoints:=8;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a1; r[3]:=0;
x[4]:=W-b; y[4]:=a1; r[4]:=0;
x[5]:=W-b; y[5]:=c; r[5]:=0;
x[6]:=b; y[6]:=c; r[6]:=0;
x[7]:=b; y[7]:=a1; r[7]:=0;
x[8]:=0; y[8]:=a1; r[8]:=0;
END
ELSE IF (Type=3) OR (Type=7) THEN
BEGIN
nPoints:=4;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=c; r[3]:=0;
x[4]:=0; y[4]:=c; r[5]:=0;
END
ELSE IF Type=4 THEN
BEGIN
nPoints:=9;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a1; r[3]:=0;
x[4]:=W-b; y[4]:=a1; r[4]:=0;
x[5]:=W-b; y[5]:=a4; r[5]:=0;
x[6]:=W/2; y[6]:=c; r[6]:=-1;
x[7]:=b; y[7]:=a4; r[7]:=0;
x[8]:=b; y[8]:=a1; r[8]:=0;
x[9]:=0; y[9]:=a1; r[9]:=0;
END
ELSE IF (Type=5) OR (Type=6) THEN
BEGIN
nPoints:=12;
x[1]:=0; y[1]:=0;
x[2]:=W; y[2]:=0;
x[3]:=W; y[3]:=a1;
x[4]:=W-b; y[4]:=a1;
x[5]:=W-b; y[5]:=c;
x[6]:=2*b+wr; y[6]:=c;
x[7]:=2*b+wr; y[7]:=a1;
x[8]:=b+wr; y[8]:=a1;
x[9]:=b+wr; y[9]:=c;
x[10]:=b; y[10]:=c;
x[11]:=b; y[11]:=a1;
x[12]:=0; y[12]:=a1;
r[1]:=rf;
r[2]:=rf;
FOR k:=3 TO 12 DO
r[k]:=0;
END
ELSE IF Type=8 THEN
BEGIN
nPoints:=8;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a6; r[3]:=0;
x[4]:=W/2+s4; y[4]:=a6; r[4]:=0;
x[5]:=W/2+s5; y[5]:=a3; r[5]:=0;
x[6]:=W/2-s5; y[6]:=a3; r[6]:=0;
x[7]:=W/2-s4; y[7]:=a6; r[7]:=0;
x[8]:=0; y[8]:=a6; r[8]:=0;
END
ELSE IF Type=9 THEN
BEGIN
nPoints:=5;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W/2; y[2]:=0; r[2]:=rf;
x[3]:=W/2; y[3]:=a3; r[3]:=0;
x[4]:=W/4; y[4]:=a8; r[4]:=-1;
x[5]:=0; y[5]:=a1; r[5]:=0;
END
ELSE IF Type=10 THEN
BEGIN
nPoints:=5;
x[1]:=0; y[1]:=0; r[1]:=rf;
x[2]:=W; y[2]:=0; r[2]:=rf;
x[3]:=W; y[3]:=a1; r[3]:=0;
x[4]:=W/2; y[4]:=a3; r[4]:=r4;
x[5]:=0; y[5]:=a1; r[5]:=0;
END;
IF ShowSection THEN FillPat(12)
ELSE FillPat(1);
Absolute;
ClosePoly;
j:=1;
FOR m:=1 TO 2 DO
BEGIN
BeginPoly;
FOR k:=1 TO nPoints DO
BEGIN
x1:=x0+x[k];
y1:=y0-j*(ID/2+y[k]);
DrawPoint(x1,y1,r[k]);
END;
EndPoly;
j:=-1;
END;
{
Draw rollers.
}
j:=1;
For m:=1 TO 2 DO
BEGIN
x1:=x0+W/2;
y1:=y0+j*r2;
IF (Type>4)AND(Type<>9) THEN
BEGIN
i:=1;
FOR n:=1 TO 2 DO
BEGIN
x2:=x1+i*s3;
Absolute;
MoveTo(x2,y1);
IF (Type=9) OR (Type=10) THEN
DrawRoller(dr2,dr,wr)
ELSE
DrawRoller(dr,dr2,wr);
IF (Type=8) OR (Type=10) THEN
BEGIN
Absolute;
RollerH:=LSActLayer;
HRotate(RollerH,x2, y1,Rad2Deg(-i*j*Alpha));
END;
i:=-1;
END;
END ELSE
BEGIN
Absolute;
MoveTo(x1, y1);
IF Type<>9 THEN
DrawRoller(dr,dr2,wr)
ELSE BEGIN
x1:=x0+W/4;
Absolute;
MoveTo(x1, y1);
DrawRoller(dr2,dr,wr);
Absolute;
RollerH:=LSActLayer;
HRotate(RollerH,x1, y1,Rad2Deg(j*Alpha));
END;
END;
j:=-1;
END;
GOTO 40;
{
Draw front view.
}
30:FillPat(1);
Phi:=ksp*dr/r2;
NRollers:=2*PI/Phi-1;
dPhi:=360/NRollers;
DrawWasher(x0,y0,OD,ID);
IF Type>=8 THEN
BEGIN
IF Type=8 THEN
d1:=2*r8
ELSE IF (Type=9)AND(View=2) THEN
d1:=2*r6
ELSE IF (Type=9)AND(View=3) THEN
d1:=2*r10
ELSE
d1:=2*r4;
DrawWasher(x0,y0,d1,ID);
END;
IF Type=10 THEN
DrawWasher(x0,y0,2*r4,ID);
IF (Type=9)AND(View=2) THEN
r0:=r9
ELSE IF (Type>=8) THEN
r0:=r7
ELSE r0:=r2;
Phi:=-dPhi;
FOR k:=1 TO NRollers DO
BEGIN
Phi:=Phi+dPhi;
x1:=r0*Sin(Deg2Rad(Phi));
y1:=r0*Cos(Deg2Rad(Phi));
Absolute;
MoveTo(x0+x1,y0+y1);
Relative;
Arc(-dr/2,dr/2,dr/2,-dr/2,0,360);
END;
IF (Type=9)AND(View=2) THEN
d2:=2*r11
ELSE IF (Type=4)OR(Type>=8) THEN
d2:=2*r6
ELSE
d2:=2*r3;
DrawWasher(x0,y0,OD,d2);
IF (Type=9)AND(View=2) THEN
d1:=2*r10
ELSE
d1:=2*r1;
DrawWasher(x0,y0,d1,ID);
40:Group;
PopAttrs;
GOTO 99;
98:Sysbeep;
AlrtDialog('That configuration is not possible!');
GOTO 5;
99:END;
Procedure TaperedRlrBrg;
{
⌐1997, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure draws the front or side view of tapered roller bearings.
}
LABEL 10,20,30,40,50,99;
CONST
V1minC = 0.10;
V2minC = 0.05;
U1minC = 0.08;
U2minC = 0.12;
ThetaC = 15.0;
rk1=0.25;
rk2=0.25;
rk3=0.25;
rk4=2.5;
kt1=0.30;
kt2=0.50;
kt3=1.50;
VAR
ID,OD,W1,W2,x0,y0 : REAL;
A1,A2,Alpha,Beta,Phi,dPhi,Theta,Theta1,Theta2 : REAL;
xr1,yr1,xr2,yr2,xr3,yr3,xr4,yr4 : REAL;
x1,y1,xrc,yrc,r1,r2,r3,r4,s,s1,t,cl : REAL;
r0,rr1,rr2,rr3,rb1,rb2,rb3,rb4 : REAL;
x,y,r,xt,yt,rt : ARRAY[1..14] OF REAL;
m,U1min,U2min,V1min,V2min,os,sp,c : REAL;
p1,p2,p3,p4,p5,p6,p7,p8,p9 : REAL;
p10,p11,p12 : REAL;
q1,q2,q3,q4,q5,q6,q7,q8,q9 : REAL;
q10,q11,q12,q13,q14,q15,q16,q17,q18 : REAL;
i,j,k,Type,View,nRollers : INTEGER;
Abort,ShowSection,Inch : BOOLEAN;
UPI : REAL;
Fmt : INTEGER;
UM,UM2 : STRING;
UName,DA : LONGINT;
Procedure BearingDialog;
{
This procedure creates the dialog box.
}
VAR
Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2,py3,py4 : INTEGER;
Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
VAR
scrx1,scry1,scrx2,scry2:INTEGER;
BEGIN
GetScreen(scrx1,scry1,scrx2,scry2);
x1:=((scrx1+scrx2) div 2)-(Width div 2);
x2:=x1+Width;
END;
Procedure LocateButtons(DialogType,scnh,scnw : INTEGER);
{
This procedure locates the 'OK' and 'Cancel' buttons.
}
VAR
v1,v2,v3,v4 : INTEGER;
Mac : BOOLEAN;
Procedure Swap(VAR m1,m2,m3,m4 : INTEGER);
VAR
Temp : INTEGER;
BEGIN
Temp:=m1;
m1:=m3;
m3:=Temp;
Temp:=m2;
m2:=m4;
m4:=Temp;
END; {of Swap}
BEGIN
Mac:=FALSE;
GetVersion(v1,v2,v3,v4);
IF v4 = 1 THEN Mac:=TRUE;
IF DialogType = 1 THEN
BEGIN
px1:=(scnw DIV 2) - 80;
px2:=(scnw DIV 2) - 10;
px3:=(scnw DIV 2) + 10;
px4:=(scnw DIV 2) + 80;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE IF DialogType = 2 THEN
BEGIN
px1:=scnw - 180;
px2:=scnw - 110;
px3:=scnw - 90;
px4:=scnw - 20;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE
BEGIN
px1:=scnw - 90;
px2:=scnw - 20;
px3:=px1;
px4:=px2;
py1:=scnh -70;
py2:=scnh - 50;
py3:=scnh - 40;
py4:=scnh - 20;
IF Mac THEN SWAP(py1,py2,py3,py4);
END;
END; {of Locate Buttons}
Procedure MakeDialog;
{
This procedure defines the dialog.
}
CONST
y1=100;
scnw=360;
scnh=340;
DialogType = 2;
VAR
h,h1 : INTEGER;
BEGIN
AlignScr(scnw,x1,x2);
y2:=y1+scnh;
LocateButtons(DialogType,scnh,scnw);
BeginDialog(1,1,x1,y1,x2,y2);
AddButton('OK',1,1,px1,py1,px2,py2);
AddButton('Cancel',2,1,px3,py3,px4,py4);
h:=35;
AddField('Type:',17,1,20,44-h,120,60-h);
AddButton('Single Row',14,3,20,65-h,120,80-h);
AddButton('Two row, double cup single cone',15,3,20,85-h,250,100-h);
AddButton('Two row, double cone single cup',16,3,20,105-h,250,120-h);
AddField('View:',10,1,270,44-h,315,60-h);
AddButton('Section',11,3,270,65-h,350,80-h);
AddButton('Front',12,3,270,85-h,350,100-h);
AddButton('Rear',13,3,270,105-h,350,120-h);
h1:=5-h;
AddField('Series:',22,1,20,h1+134,65,h1+150);
AddButton('Inch',23,3,75,h1+135,125,h1+150);
AddButton('Metric (mm)',24,3,135,h1+135,235,h1+150);
AddField('Inside Diameter:',4,1,20,h1+164,175,h1+180);
AddField('',5,2,180,h1+165,245,h1+180);
AddField('in',35,1,255,h1+164,285,h1+180);
AddField('Outside Diameter:',6,1,20,h1+189,175,h1+205);
AddField('',7,2,180,h1+190,245,h1+205);
AddField('in',36,1,255,h1+189,285,h1+205);
AddField('Width of inner race:',8,1,20,h1+214,175,h1+230);
AddField('',9,2,180,h1+215,245,h1+230);
AddField('in',37,1,255,h1+214,285,h1+230);
AddField('Width of outer race:',29,1,20,h1+239,175,h1+255);
AddField('',30,2,180,h1+240,245,h1+255);
AddField('in',38,1,255,h1+239,285,h1+255);
AddField('Space between rows:',31,1,20,h1+264,175,h1+280);
AddField('',32,2,180,h1+265,245,h1+280);
AddField('in',39,1,255,h1+264,285,h1+280);
h1:=h1+25;
AddButton('Show Section Lines',20,2,20,h1+270,170,h1+285);
EndDialog;
END;
BEGIN
MakeDialog;
END;
Procedure GetInfo;
{
This procedure displays the dialog box and retrieves the information.
}
LABEL 10,15,20,25,30;
VAR
Done,OK : BOOLEAN;
Item,k : INTEGER;
RFlag : ARRAY[1..3] OF INTEGER;
Procedure SetRButton(i,Item : INTEGER);
BEGIN
IF NOT ItemSel(Item) THEN
BEGIN
SetItem(RFlag[i],FALSE);
SetItem(Item,TRUE);
RFlag[i]:=Item;
END;
END;
BEGIN
Done:=FALSE;
Abort:=FALSE;
View:=1;
Type:=1;
ShowSection:=TRUE;
Inch:=TRUE;
RFlag[1]:=Type+13;
RFlag[2]:=11;
RFlag[3]:=23;
GetDialog(1);
SetTitle('Tapered Roller Bearings');
SetItem(RFlag[1],TRUE);
SetItem(RFlag[2],TRUE);
SetItem(RFlag[3],TRUE);
SetItem(20,ShowSection);
SetField(5,Num2Str(4,ID));
SetField(7,Num2Str(4,OD));
SetField(9,Num2Str(4,W1));
SetField(30,Num2Str(4,W2));
SetField(32,'<n/a>');
10:SelField(5);
GOTO 20;
15:SelField(9);
20:REPEAT
DialogEvent(Item);
IF Item=1 THEN
Done:=TRUE;
IF Item=2 THEN
BEGIN
Done:=TRUE;
Abort:=TRUE;
END;
IF (Item>=11) AND (Item<=13) THEN
BEGIN
SetRButton(2,Item);
View:=Item-10;
END;
IF (Item>=14) AND (Item<=16) THEN
BEGIN
SetRButton(1,Item);
Type:=Item-13;
IF Item=15 THEN
SetField(32,Num2StrF(sp))
ELSE
SetField(32,'<n/a>');
END;
IF Item=20 THEN
BEGIN
ShowSection:=NOT ShowSection;
SetItem(Item,ShowSection);
END;
IF (Item=23) AND (NOT ItemSel(23)) THEN
BEGIN
SetRButton(3,Item);
FOR k:=35 TO 39 DO
SetField(k,'in');
Inch:=TRUE;
END;
IF (Item=24) AND (NOT ItemSel(24))THEN
BEGIN
SetRButton(3,Item);
FOR k:=35 TO 39 DO
SetField(k,'mm');
Inch:=FALSE;
END;
UNTIL DONE;
IF Abort THEN GOTO 30;
OK:=ValidNumStr(GetField(5),ID);
OK:=ValidNumStr(GetField(7),OD);
OK:=ValidNumStr(GetField(9),W1);
OK:=ValidNumStr(GetField(30),W2);
OK:=ValidNumStr(GetField(32),sp);
IF ID < OD THEN GOTO 25;
SysBeep;
AlrtDialog('ID must be less than OD!');
Done:=FALSE;
GOTO 10;
25:IF W2 <= W1 THEN GOTO 30;
SysBeep;
AlrtDialog('Width of outer race must be less than or equal to inner race!');
Done:=FALSE;
GOTO 15;
30:ClrDialog;
END;
Procedure DrawWasher(x0,y0,OD,ID:REAL);
VAR
r1,r2 : REAL;
x,y,r : ARRAY[1..13] OF REAL;
n : INTEGER;
BEGIN
r1:=OD/2;
r2:=ID/2;
x[1]:=0; y[1]:=r1; r[1]:=0;
x[2]:=r1; y[2]:=r1; r[2]:=r1;
x[3]:=r1; y[3]:=-r1; r[3]:=r1;
x[4]:=-r1; y[4]:=-r1; r[4]:=r1;
x[5]:=-r1; y[5]:=r1; r[5]:=r1;
x[6]:=0; y[6]:=r1; r[6]:=0;
x[7]:=0; y[7]:=r2; r[7]:=-1;
x[8]:=-r2; y[8]:=r2; r[8]:=r2;
x[9]:=-r2; y[9]:=-r2; r[9]:=r2;
x[10]:=r2; y[10]:=-r2; r[10]:=r2;
x[11]:=r2; y[11]:=r2; r[11]:=r2;
x[12]:=0; y[12]:=r2; r[12]:=0;
x[13]:=0; y[13]:=r1; r[13]:=-1;
Absolute;
MoveTo(x0,y0);
OpenPoly;
BeginPoly;
FOR n:=1 TO 13 DO
BEGIN
x[n]:=x[n]+x0;
y[n]:=y[n]+y0;
IF r[n]<0 THEN
MoveTo(x[n],y[n])
ELSE IF r[n]=0 THEN
LineTo(x[n],y[n])
ELSE
ArcTo(x[n],y[n],r[n]);
END;
EndPoly;
END;
Procedure DrawPoly(NPoints:INTEGER);
VAR
k : INTEGER;
BEGIN
Absolute;
MoveTo(xt[1],yt[1]);
BeginPoly;
FOR k:=1 TO Npoints DO
BEGIN
IF r[k]<0 THEN
MoveTo(xt[k],yt[k])
ELSE IF r[k]=0 THEN
LineTo(xt[k],yt[k])
ELSE
ArcTo(xt[k],yt[k],r[k]);
END;
EndPoly;
END;
{
Main program.
}
BEGIN
PushAttrs;
{
Display dialog box and get information.
}
OD:=2.375;
ID:=1.125;
W1:=1.0000;
W2:=0.87500;
sp:=0.1250;
BearingDialog;
SetCursor(ArrowC);
GetInfo;
IF Abort THEN GOTO 99;
DSelectAll;
GetPt(x0,y0);
{
Get units per inch and adjust parameters.
}
GetUnits(UName,DA,Fmt,UPI,UM,UM2);
IF Inch THEN
BEGIN
ID:=ID*UPI;
OD:=OD*UPI;
W1:=W1*UPI;
W2:=W2*UPI;
END ELSE
BEGIN
ID:=ID*UPI/25.4;
OD:=OD*UPI/25.4;
W1:=W1*UPI/25.4;
W2:=W2*UPI/25.4;
END;
{
Determine roller size and calculate bearing dimensions.
}
IF Type=2 THEN
BEGIN
c:=0;
sp:=sp/2;
W1:=W1/2-sp;
W2:=W2/2-sp;
END ELSE IF Type=3 THEN
BEGIN
sp:=0;
W1:=W1/2;
W2:=W2/2;
c:=W1;
END ELSE
BEGIN
sp:=0;
c:=0;
END;
Theta:=Deg2Rad(ThetaC);
xrc:=-(W1+W2)/4;
yrc:=+(OD+ID)/4;
m:=(OD+ID)/(4*Tan(Theta)) - (W1+W2)/4;
U1min:=U1minC*(OD-ID)/2;
U2min:=U2minC*(OD-ID)/2;
V1min:=V1minC*W1;
V2min:=V2minC*W2;
Theta1:=ArcTan((ID/2+U1min)/m);
Theta2:=ArcTan((OD/2-U2min)/(m+W2-V2min));
Alpha:=Theta-Theta1;
IF (Theta2-Theta)<Alpha THEN
Alpha:=Theta2-Theta;
Theta1:=Theta-Alpha;
Theta2:=Theta+Alpha;
xr1:=V2min;
yr1:=(m+V2min)*Tan(Theta2);
p1:=xr1;
p2:=W2-2*p1;
q1:=p1*Tan(Theta2);
q7:=yr1-m*Tan(Theta);
q5:=q7-p1*Tan(Theta);
rr1:=q5*Cos(Theta);
p4:=rr1*Sin(Theta);
q4:=rr1*Cos(Theta);
xr4:=xr1+2*p4;
yr4:=yr1-2*q4;
s1:=p2/Cos(Theta2);
p3:=s1*Cos(Theta1);
q3:=s1*Sin(Theta1);
xr3:=p3+xr4;
IF (W1-xr3) < V1min THEN BEGIN
xr3:=W1-V1min;
p3:=xr3-xr4;
s1:=p3/Cos(Theta1);
q3:=s1*Sin(Theta1);
p2:=s1*Cos(Theta2);
END;
yr3:=yr4+q3;
q2:=p2*Tan(Theta2);
xr2:=p2+xr1;
yr2:=yr1+q2;
rr2:=(yr2-yr3)/(2*Cos(Theta));
q8:=OD/2-m*Tan(Theta)-q7+q1;
q9:=q8-W2*Tan(Theta2);
t:=kt1*rr1;
cl:=kt2*V1min;
os:=kt3*t;
p8:=t*Sin(Theta2);
q6:=rk3*rr2;
p6:=q6*Tan(Theta);
p11:=W1-xr3+p6;
p7:=t+W1-p11/2-t*Sin(Theta2);
p9:=p7+p8-t;
q10:=t*Tan(Theta2);
q11:=p7*Tan(Theta2);
q13:=yr1-m*Tan(Theta)-q1;
q12:=q13-q10;
q14:=t*Cos(Theta2);
q15:=p9*Tan(Theta2);
q18:=rk3*rr1;
p12:=q18*Tan(Theta);
p10:=xr4-p12;
q16:=yr4-ID/2+q18;
q17:=yr3-ID/2+q6;
r1:=rk1*q8;
r2:=rk2*q17;
r3:=2*t;
r4:=t;
{
Draw bearing.
}
IF (View=2) OR (View=3) THEN GOTO 40;
{
Section view.
}
i:=1;
j:=1;
{
Draw outer race.
}
10:
x[1]:=0; y[1]:=OD/2-q8;
x[2]:=-W2; y[2]:=OD/2-q9;
x[3]:=x[2]; y[3]:=OD/2;
x[4]:=0; y[4]:=y[3];
FOR k:=1 TO 4 DO
BEGIN
xt[k]:=x0+i*(x[k]-sp+c);
yt[k]:=y0+j*y[k];
r[k]:=0;
END;
r[4]:=r1;
IF j=1 THEN
BEGIN
FillPat(1);
Rect(xt[2],yt[2],xt[1],2*y0-yt[2]);
END;
IF (Type=2)AND(i=1)AND(j=1) THEN
BEGIN
FillPat(1);
Rect(xt[4],yt[4]-r1, xt[4]+2*sp,2*y0-(yt[4]-r1));
END;
Absolute;
IF ShowSection THEN FillPat(24)
ELSE FillPat(1);
ClosePoly;
DrawPoly(4);
{
Draw retainer.
}
x[1]:=0; y[1]:=m*Tan(Theta);
x[2]:=x[1]+t; y[2]:=y[1];
x[3]:=x[2]; y[3]:=y[1]+q12;
x[4]:=x[3]-p7; y[4]:=y[3]+q11;
x[5]:=x[4]-p8; y[5]:=y[4]-q14;
x[6]:=x[1]; y[6]:=y[5]-q15;
FOR k:=1 TO 6 DO
BEGIN
xt[k]:=x0+i*(x[k]-sp+c);
yt[k]:=y0+j*(y[k]-os);
r[k]:=0;
END;
r[3]:=r3;
r[6]:=r4;
IF j=1 THEN
BEGIN
FillPat(1);
Poly(xt[5],yt[5], xt[2],yt[6], xt[2],2*y0-yt[6], xt[5],2*y0-yt[5]);
Rect(xt[1],yt[1], xt[2],2*y0-yt[2]);
END;
IF ShowSection THEN FillPat(2)
ELSE FillPat(1);
ClosePoly;
DrawPoly(6);
{
Draw inner race.
}
x[1]:=0; y[1]:=ID/2+q16;
x[2]:=-p10; y[2]:=y[1];
x[3]:=x[2]-p12; y[3]:=y[2]-q18;
x[4]:=-(W1-p11+p6); y[4]:=ID/2+q17-q6;
x[5]:=x[4]+p6; y[5]:=ID/2+q17;
x[6]:=-W1; y[6]:=y[5];
x[7]:=-W1; y[7]:=ID/2;
x[8]:=0; y[8]:=ID/2;
IF Type <> 3 THEN BEGIN
FOR k:=1 TO 8 DO
BEGIN
xt[k]:=x0+i*(x[k]-sp+c);
yt[k]:=y0+j*y[k];
r[k]:=0;
END;
r[7]:=r2;
IF j=1 THEN
BEGIN
FillPat(1);
Rect(xt[1],yt[1],xt[6],2*y0-yt[1]);
END;
IF ShowSection THEN FillPat(12)
ELSE FillPat(1);
DrawPoly(8);
END ELSE IF (i=-1) THEN
BEGIN
FOR k:=1 TO 5 DO
BEGIN
xt[k]:=x0+i*(x[k]-sp+c);
yt[k]:=y0+j*y[k];
r[k]:=0;
END;
FOR k:=6 TO 10 DO
BEGIN
xt[k]:=x0-i*(x[11-k]-sp+c);
yt[k]:=y0+j*y[11-k];
r[k]:=r[11-k];
END;
xt[11]:=x0-i*(x[8]-sp+c);
yt[11]:=y0+j*y[8];
r[11]:=0;
xt[12]:=x0+i*(x[8]-sp+c);
yt[12]:=y0+j*y[8];
r[12]:=0;
IF j=1 THEN
BEGIN
FillPat(1);
Rect(xt[1],yt[1], xt[11],2*y0-yt[1]);
END;
IF ShowSection THEN FillPat(12)
ELSE FillPat(1);
ClosePoly;
DrawPoly(12);
END;
{
Draw rollers.
}
x[1]:=-xr1; y[1]:=yr1; r[1]:=0;
x[2]:=-xr2; y[2]:=yr2; r[2]:=0;
x[3]:=-xr3; y[3]:=yr3; r[3]:=0;
x[4]:=-xr4; y[4]:=yr4; r[4]:=0;
Absolute;
FOR k:=1 TO 4 DO
BEGIN
xt[k]:=x0+i*(x[k]-sp+c);
yt[k]:=y0+j*y[k];
END;
FillPat(1);
ClosePoly;
Absolute;
DrawPoly(4);
IF j=-1 THEN GOTO 20;
j:=-1;
GOTO 10;
20:IF (i=-1) OR (Type=1) THEN GOTO 30;
i:=-1;
j:=1;
GOTO 10;
{
Draw rear view.
}
40:FillPat(1);
IF ((View=2)AND(Type<>2)) OR (Type=3) THEN GOTO 50;
rr3:=rr2*Cos(Theta);
r0:=yr3+rr3;
rb3:=OD/2-q9;
Phi:=rk4*rr3/r0;
NRollers:=2*PI/Phi;
dPhi:=360/NRollers;
FillPat(1);
DrawWasher(x0,y0,OD,ID);
FillPat(0);
Absolute;
MoveTo(x0,y0);
Relative;
Arc(-rb3,rb3,rb3,-rb3,0,360);
Phi:=-dPhi;
FOR k:=1 TO NRollers DO
BEGIN
Phi:=Phi+dPhi;
x1:=r0*Sin(Deg2Rad(Phi));
y1:=r0*Cos(Deg2Rad(Phi));
Absolute;
MoveTo(x0+x1,y0+y1);
Relative;
Arc(-rr3,rr3,rr3,-rr3,0,360);
END;
rb1:=m*Tan(Theta)-os+q11+q12;
rb2:=rb1-t*Cos(Theta2);
FillPat(1);
DrawWasher(x0,y0,2*rb1,2*rb2);
rb1:=ID/2+q17;
rb2:=ID/2;
DrawWasher(x0,y0,2*rb1,2*rb2);
GOTO 30;
{
Draw front view.
}
50:FillPat(1);
DrawWasher(x0,y0,OD,ID);
Absolute;
rb1:=OD/2-q8;
rb2:=ID/2+q16;
MoveTo(x0,y0);
Relative;
FillPat(0);
Arc(-rb1,rb1,rb1,-rb1,0,360);
Arc(-rb2,rb2,rb2,-rb2,0,360);
30:Group;
PopAttrs;
99:END; {of TaperedRlrBrg}
Procedure ThrustBrg;
{
⌐1996, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure draws the front or side view of tapered roller bearings.
}
LABEL 99;
CONST
nPoints = 6;
k1 = 0.25; {Radius of ball or roller}
k2 = 0.75; {Small radius of tapered roller}
k3 = 0.125; {Fillet radius}
k4 = 1.25; {Space between washers}
k5 = 0.94; {Width of spacer}
k6 = 0.63; {Thickness of spacer}
k7 = 0.75; {Length of roller}
k8 = 0.5; {Shape of spherical roller}
VAR
ID,OD,T,T1,T2,tw,x0,y0,x1,y1 : REAL;
rf,rr1,rr2,rr3,s,w,wr,hr : REAL;
dRoller,ll,lr,idRet,odRet : REAL;
x,y,r : ARRAY[1..nPoints] OF REAL;
i,j,k,m,Style,Type,View,nWashers : INTEGER;
Abort,ShowSect,Inch : BOOLEAN;
UPI : REAL;
Fmt : INTEGER;
UM,UM2 : STRING;
UName,DA : LONGINT;
Procedure BearingDialog;
{
This procedure creates the dialog box.
}
VAR
Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2,py3,py4 : INTEGER;
Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
VAR
scrx1,scry1,scrx2,scry2:INTEGER;
BEGIN
GetScreen(scrx1,scry1,scrx2,scry2);
x1:=((scrx1+scrx2) div 2)-(Width div 2);
x2:=x1+Width;
END;
Procedure LocateButtons(DialogType,scnh,scnw : INTEGER);
{
This procedure locates the 'OK' and 'Cancel' buttons.
}
VAR
v1,v2,v3,v4 : INTEGER;
Mac : BOOLEAN;
Procedure Swap(VAR m1,m2,m3,m4 : INTEGER);
VAR
Temp : INTEGER;
BEGIN
Temp:=m1;
m1:=m3;
m3:=Temp;
Temp:=m2;
m2:=m4;
m4:=Temp;
END; {of Swap}
BEGIN
Mac:=FALSE;
GetVersion(v1,v2,v3,v4);
IF v4 = 1 THEN Mac:=TRUE;
IF DialogType = 1 THEN
BEGIN
px1:=(scnw DIV 2) - 80;
px2:=(scnw DIV 2) - 10;
px3:=(scnw DIV 2) + 10;
px4:=(scnw DIV 2) + 80;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE IF DialogType = 2 THEN
BEGIN
px1:=scnw - 180;
px2:=scnw - 110;
px3:=scnw - 90;
px4:=scnw - 20;
IF Mac THEN SWAP(px1,px2,px3,px4);
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
END ELSE
BEGIN
px1:=scnw - 90;
px2:=scnw - 20;
px3:=px1;
px4:=px2;
py1:=scnh -70;
py2:=scnh - 50;
py3:=scnh - 40;
py4:=scnh - 20;
IF Mac THEN SWAP(py1,py2,py3,py4);
END;
END; {of Locate Buttons}
Procedure MakeDialog;
CONST
y1=100;
scnw=310;
scnh=370;
DialogType = 2;
VAR
h,h1 : INTEGER;
BEGIN
AlignScr(scnw,x1,x2);
y2:=y1+scnh;
LocateButtons(DialogType,scnh,scnw);
BeginDialog(1,1,x1,y1,x2,y2);
AddButton('OK',1,1,px1,py1,px2,py2);
AddButton('Cancel',2,1,px3,py3,px4,py4);
h:=35;
AddField('Type:',21,1,20,44-h,100,60-h);
AddButton('Single Ball',22,3,20,65-h,130,80-h);
AddButton('Double Ball',23,3,20,85-h,130,100-h);
AddButton('Roller',24,3,20,105-h,100,120-h);
AddButton('Tapered Roller',25,3,20,125-h,140,140-h);
AddButton('Spherical Roller',26,3,20,145-h,140,160-h);
AddField('Style of Raceways:',30,1,160,44-h,290,60-h);
AddButton('Grooved',31,3,160,65-h,240,80-h);
AddButton('Flat',32,3,160,85-h,240,100-h);
h1:=40-h;
AddField('Series:',8,1,20,h1+134,65,h1+150);
AddButton('Inch',9,3,75,h1+135,125,h1+150);
AddButton('Metric (mm)',10,3,135,h1+135,235,h1+150);
AddField('Inside Diameter:',11,1,20,h1+164,145,h1+180);
AddField('',12,2,160,h1+165,225,h1+180);
AddField('Outside Diameter:',13,1,20,h1+189,145,h1+205);
AddField('',14,2,160,h1+190,225,h1+205);
AddField('Thickness:',15,1,20,h1+214,145,h1+230);
AddField('',16,2,160,h1+215,225,h1+230);
AddField('in',17,1,235,h1+164,265,h1+180);
AddField('in',18,1,235,h1+189,265,h1+205);
AddField('in',19,1,235,h1+214,265,h1+230);
h1:=60-h;
AddField('View:',5,1,20,229+h1,60,245+h1);
AddButton('Section',6,3,70,230+h1,135,245+h1);
AddButton('Top',7,3,145,230+h1,200,245+h1);
h1:=70-h;
AddButton('Show Section Lines',20,2,20,h1+250,170,h1+265);
EndDialog;
END;
BEGIN
MakeDialog;
END;
Procedure GetInfo;
{
This procedure displays the dialog box and retrieves the information.
}
LABEL 10,25,30;
VAR
Done,OK : BOOLEAN;
Item,k : INTEGER;
RFlag : ARRAY[1..4] OF INTEGER;
Procedure SetRButton(i,Item : INTEGER);
BEGIN
IF NOT ItemSel(Item) THEN
BEGIN
SetItem(RFlag[i],FALSE);
SetItem(Item,TRUE);
RFlag[i]:=Item;
END;
END;
BEGIN
Done:=FALSE;
Abort:=FALSE;
View:=1;
Type:=1;
Style:=1;
ShowSect:=TRUE;
Inch:=TRUE;
RFlag[1]:=Type+21;
RFlag[2]:=View+5;
RFlag[3]:=9;
RFlag[4]:=Style+30;
GetDialog(1);
SetTitle('Thrust Bearings');
SetItem(RFlag[1],TRUE);
SetItem(RFlag[2],TRUE);
SetItem(RFlag[3],TRUE);
SetItem(RFlag[4],TRUE);
SetItem(20,ShowSect);
SetField(12,Num2Str(4,ID));
SetField(14,Num2Str(4,OD));
SetField(16,Num2Str(4,T));
10:SelField(12);
REPEAT
DialogEvent(Item);
IF Item=1 THEN
Done:=TRUE;
IF Item=2 THEN
BEGIN
Done:=TRUE;
Abort:=TRUE;
END;
IF (Item=6) OR (Item=7) THEN
BEGIN
SetRButton(2,Item);
View:=Item-5;
END;
IF (Item=9) AND (NOT ItemSel(9)) THEN
BEGIN
SetRButton(3,Item);
FOR k:=17 TO 19 DO
SetField(k,'in');
Inch:=TRUE;
END;
IF (Item=10) AND (NOT ItemSel(10))THEN
BEGIN
SetRButton(3,Item);
FOR k:=17 TO 19 DO
SetField(k,'mm');
Inch:=FALSE;
END;
IF Item=20 THEN
BEGIN
ShowSect:=NOT ShowSect;
SetItem(Item,ShowSect);
END;
IF (Item>=21) AND (Item<=27) THEN
BEGIN
SetRButton(1,Item);
Type:=Item-21;
END;
IF (Item=31) OR (Item=32) THEN
BEGIN
SetRButton(4,Item);
Style:=Item-30;
END;
UNTIL DONE;
IF Abort THEN GOTO 30;
OK:=ValidNumStr(GetField(12),ID);
OK:=ValidNumStr(GetField(14),OD);
OK:=ValidNumStr(GetField(16),T);
IF ID < OD THEN GOTO 30;
SysBeep;
AlrtDialog('ID must be less than OD!');
Done:=FALSE;
GOTO 10;
30:ClrDialog;
END;
Procedure DrawWasher(x0,y0,OD,ID:REAL);
VAR
r1,r2 : REAL;
x,y,r : ARRAY[1..13] OF REAL;
n : INTEGER;
BEGIN
r1:=OD/2;
r2:=ID/2;
x[1]:=0; y[1]:=r1; r[1]:=0;
x[2]:=r1; y[2]:=r1; r[2]:=r1;
x[3]:=r1; y[3]:=-r1; r[3]:=r1;
x[4]:=-r1; y[4]:=-r1; r[4]:=r1;
x[5]:=-r1; y[5]:=r1; r[5]:=r1;
x[6]:=0; y[6]:=r1; r[6]:=0;
x[7]:=0; y[7]:=r2; r[7]:=-1;
x[8]:=-r2; y[8]:=r2; r[8]:=r2;
x[9]:=-r2; y[9]:=-r2; r[9]:=r2;
x[10]:=r2; y[10]:=-r2; r[10]:=r2;
x[11]:=r2; y[11]:=r2; r[11]:=r2;
x[12]:=0; y[12]:=r2; r[12]:=0;
x[13]:=0; y[13]:=r1; r[13]:=-1;
Absolute;
MoveTo(x0,y0);
OpenPoly;
BeginPoly;
FOR n:=1 TO 13 DO
BEGIN
x[n]:=x[n]+x0;
y[n]:=y[n]+y0;
IF r[n]<0 THEN
MoveTo(x[n],y[n])
ELSE IF r[n]=0 THEN
LineTo(x[n],y[n])
ELSE
ArcTo(x[n],y[n],r[n]);
END;
EndPoly;
END;
Procedure DrawPoint(x,y,r:REAL);
BEGIN
IF r<0 THEN
CurveThrough(x,y)
ELSE IF r=0 THEN
LineTo(x,y)
ELSE
ArcTo(x,y,r);
END;
{
Main program.
}
BEGIN
PushAttrs;
{
Display dialog box and get information.
}
OD:=3.000;
ID:=2.000;
T:=0.500;
BearingDialog;
SetCursor(ArrowC);
GetInfo;
IF Abort THEN GOTO 99;
DSelectAll;
GetPt(x0,y0);
{
Get units per inch and adjust parameters.
}
GetUnits(UName,DA,Fmt,UPI,UM,UM2);
IF Inch THEN
BEGIN
ID:=ID*UPI;
OD:=OD*UPI;
T:=T*UPI;
END ELSE
BEGIN
ID:=ID*UPI/25.4;
OD:=OD*UPI/25.4;
T:=T*UPI/25.4;
END;
{
Draw top view.
}
IF View=2 THEN
BEGIN
FillPat(1);
DrawWasher(x0,y0,OD,ID);
GOTO 99;
END;
{
Determine roller size and calculate bearing dimensions.
}
nWashers:=2;
W:=(OD-ID)/2;
IF Type=2 THEN
BEGIN
T1:=T;
T:=2*T1/(3*(1+k1*k2*k4/3));
T2:=2*(T1-k1*k2*k4*W/2)/3;
IF T2<T THEN T:=T2;
IF Style=2 THEN
BEGIN
T2:=2*(T1-W)/3;
IF T2<T THEN T:=T2;
END;
nWashers:=3;
END;
rr1:=k1*W;
IF rr1 > k1*T THEN rr1:=k1*T;
rr2:=k2*rr1;
rf:=k3*W;
IF rf > k3*T THEN rf:=k3*T;
IF Style=1 THEN
s:=k4*rr2
ELSE
s:=2*rr1;
tw:=(T-s)/2;
wr:=k5*W;
hr:=k6*s;
lr:=k7*W;
rr3:=(rr1+rr2)/2;
ll:=k8*lr;
odRet:=(OD+ID)/2+wr;
idRet:=odRet-2*wr;
dRoller:=(OD+ID)/2;
{
Draw bearing.
}
{
Draw washers.
}
x1:=x0-OD/2;
y1:=y0-(tw+s);
ClosePoly;
Absolute;
FOR k:=1 TO nWashers DO
BEGIN
y1:=y1+tw+s;
x[1]:=x1; y[1]:=y1; r[1]:=0;
x[2]:=x1; y[2]:=y1+tw; r[2]:=0;
x[3]:=x1+OD; y[3]:=y1+tw; r[3]:=0;
x[4]:=x1+OD; y[4]:=y1; r[4]:=0;
IF k=1 THEN
BEGIN
r[1]:=rf;
r[4]:=rf;
END ELSE IF ((Type<>2)AND(k=2))OR(k=3) THEN
BEGIN
r[2]:=rf;
r[3]:=rf;
END;
MoveTo(x1,y1);
FillPat(1);
BeginPoly;
FOR m:=1 TO 4 DO
DrawPoint(x[m],y[m],r[m]);
EndPoly;
IF ShowSect THEN
BEGIN
IF k=1 THEN
FillPat(12)
ELSE IF k=2 THEN
FillPat(24)
ELSE FillPat(12);
END ELSE FillPat(1);
x[3]:=x[1]+W;
x[4]:=x[1]+W;
BeginPoly;
FOR m:=1 TO 4 DO
DrawPoint(x[m],y[m],r[m]);
EndPoly;
x[1]:=x[1]+OD;
x[2]:=x[1];
x[3]:=x[1]-W;
x[4]:=x[3];
BeginPoly;
FOR m:=1 TO 4 DO
DrawPoint(x[m],y[m],r[m]);
EndPoly;
END;
{
Draw retainer(s).
}
x1:=x0;
y1:=y0-s/2;
FOR k:=1 TO nWashers-1 DO
BEGIN
y1:=y1+tw+s;
FillPat(1);
Absolute;
MoveTo(x1,y1);
Relative;
Rect(-odRet/2,hr/2,odRet/2,-hr/2);
IF ShowSect THEN FillPat(2)
ELSE FillPat(1);
Rect(-odRet/2,hr/2,-idRet/2,-hr/2);
Rect(odRet/2,hr/2,idRet/2,-hr/2);
END;
{
Draw rollers.
}
FillPat(1);
x1:=x0-dRoller/2;
y1:=y0+T/2;
Absolute;
MoveTo(x1,y1);
IF (Type=1) OR (Type=2) THEN
BEGIN
Relative;
Arc(-rr1,rr1,rr1,-rr1,0,360);
Move(dRoller,0);
Arc(-rr1,rr1,rr1,-rr1,0,360);
IF Type=2 THEN
BEGIN
Move(0,tw+s);
Arc(-rr1,rr1,rr1,-rr1,0,360);
Move(-dRoller,0);
Arc(-rr1,rr1,rr1,-rr1,0,360);
END;
END
ELSE IF Type=3 THEN
BEGIN
Relative;
Rect(-lr/2,rr1,lr/2,-rr1);
Move(dRoller,0);
Rect(-lr/2,rr1,lr/2,-rr1);
END
ELSE IF Type=4 THEN
BEGIN
Relative;
Move(-lr/2,rr1);
Poly(0,0, lr,-(rr1-rr2), 0,-2*rr2, -lr,-(rr1-rr2));
Move(dRoller+lr,0);
Poly(0,0, -lr,(rr1-rr2), 0,2*rr2, lr,(rr1-rr2));
END
ELSE IF Type=5 THEN
BEGIN
x1:=(dRoller+lr)/2;
x[1]:=-x1; y[1]:=y1+rr3;
x[2]:=x[1]+ll; y[2]:=y1+rr1;
x[3]:=x[1]+lr; y[3]:=y1+rr2;
x[4]:=x[3]; y[4]:=y1-rr2;
x[5]:=x[2]; y[5]:=y1-rr1;
x[6]:=x[1]; y[6]:=y1-rr3;
r[1]:=0; r[2]:=-1; r[3]:=0;
r[4]:=0; r[5]:=-1; r[6]:=0;
Absolute;
i:=1;
FOR m:=1 TO 2 DO
BEGIN
MoveTo(x0+i*x1,y1);
BeginPoly;
FOR k:=1 TO 6 DO
DrawPoint(x0+i*x[k],y[k],r[k]);
EndPoly;
i:=-1;
END;
END;
Group;
PopAttrs;
99:END; {of ThrustBrg}
{
Main Program.
}
BEGIN
MainDialog;
SetCursor(ArrowC);
GetInfo1;
IF Abort THEN GOTO 99;
If Type=1 THEN BallBearing
ELSE If Type=2 THEN RollerBearing
ELSE If Type=3 THEN TaperedRlrBrg
ELSE If Type=4 THEN ThrustBrg;
99:END;
RUN(Bearings);