home *** CD-ROM | disk | FTP | other *** search
- Procedure RollerBearing;
- {
- (Windows vwesion)
- ⌐1996, Diehl Graphsoft, Inc.
- Developed by Tom Urie
-
- This procedure draws a roller bearing.
- }
-
- LABEL 20,30,40,99;
- CONST
- RFW=0.666667; {Used to determine width of roller {rw=W*RFW).}
- RDF=0.5; {Used to determine roller diameter.}
- RF=0.25; {Used to determine radius of fillet on inner and outer race.}
- TF=0.25; {Used to determine the amount of overlap of the inner and outer race over the roller.}
- SF=0.75; {Used to determine the spacing between rollers and, hence, the number of rollers.}
- VAR
- ID,OD,W,t,a,b,c,d,rd,rr,rc,rw : REAL;
- x0,y0,x1,y1,s : REAL;
- r,r1,r2,r3,Theta1,Theta2,Phi,DeltaPhi : REAL;
- Type,View,NRollers,n : INTEGER;
- RFlag : ARRAY[1..3] OF INTEGER;
- Ans,Abort,ShowSect,Inch,CFlag1 : BOOLEAN;
- ODS,IDS,WS,DisplayUnits : STRING;
- 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 : 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 MakeDialog;
- CONST
- y1=100;
- scnh=270; scnw=360;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px1:=scnw-160;
- px2:=scnw-100;
- px3:=scnw-80;
- px4:=scnw-20;
- py1:=scnh-40;
- py2:=scnh-20;
-
- BeginDialog(1,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px3,py1-35,px4,py2-35);
- AddButton('Cancel',2,1,px3,py1,px4,py2);
- AddField('Inside Diameter:',4,1,20,165-h,145,180-h);
- AddField('',5,2,150,165-h,225,180-h);
- AddField('Outside Diameter:',6,1,20,190-h,145,205-h);
- AddField('',7,2,150,190-h,225,205-h);
- AddField('Width:',8,1,20,215-h,145,230-h);
- AddField('',9,2,150,215-h,225,230-h);
- AddField('View:',10,1,270,135-h,315,150-h);
- AddButton('Section',11,3,270,160-h,350,175-h);
- AddButton('Front',12,3,270,180-h,325,195-h);
- AddField('Ring Configuration (Ribs-Inner/Ribs-Outer):',13,1,20,40-h,340,55-h);
- AddButton('Double/Double',14,3,20,65-h,160,80-h);
- AddButton('Double/None',15,3,20,85-h,175,100-h);
- AddButton('None/Double',16,3,20,105-h,175,120-h);
- AddButton('Single/Double',17,3,190,65-h,335,80-h);
- AddButton('Double/Single',18,3,190,85-h,340,100-h);
- AddButton('Single/Single',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,135-h,60,150-h);
- AddButton('Inch',23,3,65,135-h,115,150-h);
- AddButton('Metric (mm)',24,3,120,135-h,210,150-h);
- AddField('',25,1,233,165-h,255,180-h);
- AddField('',26,1,233,190-h,255,205-h);
- AddField('',27,1,233,215-h,255,230-h);
- EndDialog;
- END;
-
- BEGIN
- MakeDialog;
- END;
-
- Procedure GetInfo;
- {
- This procedure displays the dialox box and retrieves the information.
- }
- LABEL 10;
- VAR
- Done:boolean;
- Item:integer;
-
- 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;
- IF Ans THEN BEGIN
- Ans:=FALSE;
- GOTO 10;
- END;
- View:=1;
- Type:=1;
- ShowSect:=TRUE;
- Inch:=TRUE;
- ODS:='2.0000';
- IDS:='1.0000';
- WS:='0.625';
- RFlag[1]:=14;
- RFlag[2]:=11;
- RFlag[3]:=23;
- CFlag1:=TRUE;
- DisplayUnits:='in';
- 10:GetDialog(1);
- SetTitle('Roller Bearings');
- SetItem(RFlag[1],TRUE);
- SetItem(RFlag[2],TRUE);
- SetItem(RFlag[3],TRUE);
- SetItem(20,CFlag1);
- SetField(5,IDS);
- SetField(7,ODS);
- SetField(9,WS);
- SetField(25,DisplayUnits);
- SetField(26,DisplayUnits);
- SetField(27,DisplayUnits);
- 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
- SetItem(Item,NOT CFlag1);
- CFlag1:=NOT CFlag1;
- END;
- IF Item = 23 THEN BEGIN
- IF RFlag[3] <> Item THEN BEGIN
- SetRButton(3,Item);
- SetField(5,Num2Str(4,Str2Num(GetField(5))/25.4));
- SetField(7,Num2Str(4,Str2Num(GetField(7))/25.4));
- SetField(9,Num2Str(4,Str2Num(GetField(9))/25.4));
- 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(5,Num2Str(1,Str2Num(GetField(5))*25.4));
- SetField(7,Num2Str(1,Str2Num(GetField(7))*25.4));
- SetField(9,Num2Str(1,Str2Num(GetField(9))*25.4));
- SetField(25,'mm');
- SetField(26,'mm');
- SetField(27,'mm');
- SelField(5);
- Inch:=FALSE;
- END;
- END;
- UNTIL DONE;
- IDS:=GetField(5);
- ODS:=GetField(7);
- WS:=GetField(9);
- ID:=Str2Num(IDS);
- OD:=Str2Num(ODS);
- W:=Str2Num(WS);
- ShowSect:=CFlag1;
- ClrDialog;
- END;
-
- {
- Main program.
- }
- BEGIN
- PushAttrs;
- {
- Define defaults.
- }
- ID:=0.7500;
- OD:=1.5000;
- W:=0.6250;
- {
- Display dialog box and get information.
- }
- BearingDialog;
- DSelectAll;
- Ans:=FALSE;
- SetCursor(ArrowC);
- 20:GetInfo;
- IF Abort THEN GOTO 99;
- IF ID<OD THEN GOTO 30;
- SysBeep;
- AlrtDialog('ID must be less than OD!');
- Ans:=TRUE;
- IF Inch THEN
- DisplayUnits:='in'
- ELSE
- DisplayUnits:='mm';
- GOTO 20;
- 30:DSelectAll;
- {
- 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;
- {
- Get insertion point.
- }
- GetPt(x0,y0);
- {
- Calculate variables needed to draw bearing.
- }
- t:=(OD-ID)/2;
- rd:=RDF*t;
- rw:=RFW*W;
- rr:=rd/2;
- a:=TF*rd;
- b:=t/2-a;
- c:=b-a;
- d:=(w-rw)/2;
- rc:=RF*b;
- r1:=ID/2+b;
- r2:=OD/2-b;
- r3:=(OD+ID)/4;
- FillPat(1);
- IF View=2 THEN GOTO 40;
- {
- Draw Side View
- }
- Absolute;
- MoveTo(x0,y0-(OD/2-rc));
- Relative;
- RECT(0,0,W,(OD-2*rc));
- {
- Inner Ring
- }
- IF ShowSect THEN
- FillPat(12);
- ClosePoly;
- IF (Type=1) OR (Type=2) OR (Type=5) THEN BEGIN
- Absolute;
- MoveTo(x0,y0+r1);
- Relative;
- BeginPoly;
- ArcTo(0,-b,rc);
- ArcTo(W,0,rc);
- LineTo(0,b);
- LineTo(-d,0);
- LineTo(0,-a);
- LineTo(-rw,0);
- LineTo(0,a);
- LineTo(-d,0);
- EndPoly;
- Move(0,-2*r1);
- BeginPoly;
- ArcTo(0,b,rc);
- ArcTo(W,0,rc);
- LineTo(0,-b);
- LineTo(-d,0);
- LineTo(0,a);
- LineTo(-rw,0);
- LineTo(0,-a);
- LineTo(-d,0);
- EndPoly;
- END
- ELSE BEGIN
- Absolute;
- MoveTo(x0,y0+r1-a);
- Relative;
- BeginPoly;
- ArcTo(0,-c,rc);
- ArcTo(W,0,rc);
- IF Type=3 THEN BEGIN
- LineTo(0,c);
- LineTo(-W,0);
- END
- ELSE BEGIN
- LineTo(0,b);
- LineTo(-d,0);
- LineTo(0,-a);
- LineTo(-(w-d),0);
- END;
- EndPoly;
- Move(0,-2*(r1-a));
- BeginPoly;
- ArcTo(0,c,rc);
- ArcTo(W,0,rc);
- IF Type=3 THEN BEGIN
- LineTo(0,-c);
- LineTo(-W,0);
- END
- ELSE BEGIN
- LineTo(0,-b);
- LineTo(-d,0);
- LineTo(0,a);
- LineTo(-(w-d),0);
- END;
- EndPoly;
- END;
- {
- Draw Outer Ring.
- }
- IF ShowSect THEN
- FillPat(24);
- ClosePoly;
- IF Type=2 THEN BEGIN
- Absolute;
- MoveTo(x0,y0-(r2+a));
- Relative;
- BeginPoly;
- ArcTo(0,-c,rc);
- ArcTo(W,0,rc);
- LineTo(0,c);
- LineTo(-W,0);
- EndPoly;
- Move(0,2*(r2+a));
- BeginPoly;
- ArcTo(0,c,rc);
- ArcTo(W,0,rc);
- LineTo(0,-c);
- LineTo(-W,0);
- EndPoly;
- END
- ELSE BEGIN
- Absolute;
- MoveTo(x0,y0-r2);
- Relative;
- BeginPoly;
- ArcTo(0,-b,rc);
- ArcTo(W,0,rc);
- IF (Type=5) OR (Type=6) THEN BEGIN
- LineTo(0,c);
- LineTo(-(W-d),0);
- LineTo(0,a);
- LineTo(-d,0);
- END
- ELSE BEGIN
- LineTo(0,b);
- LineTo(-d,0);
- LineTo(0,-a);
- LineTo(-rw,0);
- LineTo(0,a);
- LineTo(-d,0);
- END;
- EndPoly;
- Move(0,2*r2);
- BeginPoly;
- ArcTo(0,b,rc);
- ArcTo(W,0,rc);
- IF (Type=5) OR (Type=6) THEN BEGIN
- LineTo(0,-c);
- LineTo(-(W-d),0);
- LineTo(0,-a);
- LineTo(-d,0);
- END
- ELSE BEGIN
- LineTo(0,-b);
- LineTo(-d,0);
- LineTo(0,a);
- LineTo(-rw,0);
- LineTo(0,-a);
- LineTo(-d,0);
- END;
- EndPoly;
- END;
- {
- Draw Rollers
- }
- FillPat(1);
- Absolute;
- MoveTo(x0+W/2,y0+r3);
- Relative;
- Rect(-rw/2,rd/2,rw/2,-rd/2);
- Move(-rw/2,rd/2);
- Line(rw,-rd);
- Move(0,rd);
- Line(-rw,-rd);
- Move(rw/2,-(2*r3-rd/2));
- Rect(-rw/2,rd/2,rw/2,-rd/2);
- Move(-rw/2,rd/2);
- Line(rw,-rd);
- Move(0,rd);
- Line(-rw,-rd);
- GOTO 99;
- {
- Draw Front View.
- }
- 40:s:=SF*rd;
- Phi:=2*s/r3;
- NRollers:=2*PI/Phi;
- DeltaPhi:=360/NRollers;
- Phi:=-DeltaPhi;
- IF Type=2 THEN
- r2:=r2+a;
- IF (Type=3) OR (Type=4) OR(Type=6) THEN
- r1:=r1-a;
- Theta1:=Rad2Deg(ArcCos((rr^2+r3^2-r2^2)/(2*rr*r3)));
- Theta2:=Rad2Deg(ArcCos((rr^2+r3^2-r1^2)/(2*rr*r3)));
- FillPat(1);
- Absolute;
- MoveTo(x0,y0);
- Relative;
- Arc(-OD/2,OD/2,OD/2,-OD/2,0,360);
- Arc(-r2,r2,r2,-r2,0,360);
- Arc(-r1,r1,r1,-r1,0,360);
- Arc(-ID/2,ID/2,ID/2,-ID/2,0,360);
- FOR n:=1 TO NRollers DO BEGIN
- Phi:=Phi+DelTaPhi;
- x1:=r3*Sin(Deg2Rad(Phi));
- y1:=r3*Cos(Deg2Rad(Phi));
- Absolute;
- MoveTo(x0+x1,y0+y1);
- Relative;
- Arc(-rr,rr,rr,-rr,(270-Theta2-Phi),(Theta2-Theta1));
- Arc(-rr,rr,rr,-rr,-(90-Theta1+Phi),(Theta2-Theta1));
- END;
- 99:Group;
- PopAttrs;
- END;
-
- Run(RollerBearing);
-