home *** CD-ROM | disk | FTP | other *** search
- Procedure DrawNut;
- {
- (c)1997, Diehl Graphsoft, Inc.
- Developed by Tom Urie
-
- This procedure draws all kinds of hex and square nuts.
- }
- LABEL 10,15,20,30,40,99;
-
- CONST
- nTypes = 5;
- Alpha = 30;
- Beta = 25;
- dik = 0.85;
- k1 = 0.75;
- k2 = 0.88;
- k3 = 0.60;
- k4 = 0.866;
-
- Filename1 = 'NutHexE.txt';
- Filename2 = 'NutHJamE.txt';
- Filename3 = 'NutSqarE.txt';
- Filename4 = 'NutSlotE.txt';
- Filename5 = 'NutM.txt';
- PathNameW = 'External\Data\';
- PathNameM = ':Externals:External Data:';
-
- VAR
- a,b,c,d,e1,e2,f,g,di,j,h,m,s,t : REAL;
- x0,y0,UPI,SF : REAL;
- f1,h1,t1,s1 : ARRAY[1..6] OF REAL;
-
- i,Class,Index,Type,View,Fmt,PathLength : INTEGER;
- nClasses : ARRAY[1..nTypes] OF INTEGER;
- RFlag : ARRAY[1..3] OF INTEGER;
-
- Sz,Size,Size1,PathName : STRING;
-
- UM,UM2 : STRING;
- Abort,Inch,Mac,SizeNotFound : BOOLEAN;
- UName,DA : LONGINT;
-
- Procedure NutDialog;
- {
- 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;
-
- 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;
- PathName:=PathNameW;
- GetVersion(v1,v2,v3,v4);
- IF v4 = 1 THEN
- BEGIN
- Mac:=TRUE;
- PathName:=PathNameM;
- END;
-
- 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 MakeDialog1;
- {
- This procedure defines the main dialog box.
- }
- CONST
- y1=100;
- scnh = 260;
- scnw =480;
- DialogType = 3;
-
- VAR
- g,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);
-
- g:=0; h:=5;
- AddField('Type of Nut (Inch Series):',5,1,20,h-1,265,15+h);
-
- AddField('Hex:',20,1,20,19+h,145,35+h);
- AddButton('Regular',30,3,20,40+h,110,55+h);
- AddButton('Heavy',31,3,20,60+h,110,75+h);
- AddButton('Thick',32,3,20,80+h,110,95+h);
- AddButton('Flat',33,3,20,100+h,110,115+h);
- AddButton('Heavy Flat',34,3,20,120+h,120,135+h);
- AddButton('Machine Screw',35,3,20,140+h,140,155+h);
-
- g:=125;h:=5;
- AddField('Hex Jam:',21,1,20+g,19+h,145+g,35+h);
- AddButton('Regular',36,3,20+g,40+h,110+g,55+h);
- AddButton('Heavy',37,3,20+g,60+h,110+g,75+h);
- AddButton('Flat',38,3,20+g,80+h,110+g,95+h);
- AddButton('Heavy Flat',39,3,20+g,100+h,120+g,115+h);
-
- g:=0;h:=150;
- AddField('Square:',22,1,20+g,19+h,145+g,35+h);
- AddButton('Regular',40,3,20+g,40+h,110+g,55+h);
- AddButton('Heavy',41,3,20+g,60+h,110+g,75+h);
- AddButton('Machine Screw',42,3,20+g,80+h,140+g,95+h);
-
- g:=125;h:=150;
- AddField('Slotted:',23,1,20+g,19+h,145+g,35+h);
- AddButton('Regular',43,3,20+g,40+h,110+g,55+h);
- AddButton('Heavy',44,3,20+g,60+h,110+g,75+h);
- AddButton('Thick',45,3,20+g,80+h,110+g,95+h);
-
- g:=250; h:=5;
- AddField('Type of Nut (Metric Series)',6,1,20+g,h-1,265+g,15+h);
-
- AddButton('Hex, Style 1',46,3,20+g,20+h,120+g,35+h);
- AddButton('Hex, Style 2',47,3,20+g,40+h,120+g,55+h);
- AddButton('Hex Jam',48,3,20+g,60+h,110+g,75+h);
- AddButton('Heavy Hex',49,3,20+g,80+h,110+g,95+h);
- AddButton('Slotted',50,3,20+g,100+h,100+g,115+h);
-
- g:=250;h:=170;
- AddField('View:',9,1,20+g,h-1,70+g,15+h);
- AddButton('Top',10,3,20+g,20+h,70+g,35+h);
- AddButton('Front',11,3,20+g,40+h,75+g,55+h);
- AddButton('Side',12,3,20+g,60+h,70+g,75+h);
-
- g:=250;h:=140;
- AddField('Size:',13,1,20+g,h-1,50+g,15+h);
- AddField('',16,2,55+g,h,125+g,15+h);
- AddField('in',18,1,133+g,h-1,160+g,15+h);
- EndDialog;
- END;
-
- BEGIN
- MakeDialog1;
- END;
-
- Procedure GetData;
- {
- This procedure opens the data file and reads the data.
- }
- LABEL 15,20,99;
-
- VAR
- k : INTEGER;
- Filename,FileS,WarningStr : STRING;
- File : ARRAY[1..nTypes] OF STRING;
-
- BEGIN
- File[1]:=Filename1;
- File[2]:=Filename2;
- File[3]:=Filename3;
- File[4]:=Filename4;
- File[5]:=Filename5;
- FileS:=File[Type];
-
- Filename:=Concat(Pathname,FileS);
- Open(Filename);
-
- IF FndError THEN
- BEGIN
- ClrDialog;
- Sysbeep;
- WarningStr:=Concat('The data file <',FileS,'> cannot be found. Check your Toolkit Manual for further explanation.');
- AlrtDialog(WarningStr);
- Abort:=TRUE;
- GoTo 99;
- END;
-
- SizeNotFound:=FALSE;
- WHILE NOT EOF(Filename) DO
- BEGIN
- k:=0;
- Read(Sz,d);
- REPEAT
- k:=k+1;
- IF Type <> 4 THEN
- Read(f1[k], h1[k])
- ELSE
- Read(f1[k], h1[k], t1[k], s1[k]);
- UNTIL k = nClasses[Type];
-
- IF Type = 5 THEN
- Read(t1[k], s1[k]);
-
- IF Sz = Size THEN GOTO 20;
- END;
-
- Close(Filename);
- 15:SysBeep;
- AlrtDialog('That size is not available!');
- SizeNotFound:=TRUE;
- GoTo 99;
-
- 20:Close(Filename);
- f:=f1[Class];
- h:=h1[Class];
- t:=t1[Class];
- s:=s1[Class];
- IF f = 0 THEN GoTo 15;
-
- 99:END;
-
- Procedure GetInfo;
- {
- This procedure displays the main dialog box and retrieves the information.
- }
- LABEL 5,10,20,99;
- VAR
- Done : BOOLEAN;
- j,k,n,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
- 5:Done:=FALSE;
- Abort:=FALSE;
-
- Index:=1;
- View:=1;
- Inch:=TRUE;
- RFlag[1]:=Index+29;
- RFlag[2]:=View+9;
-
- GetDialog(1);
- SetTitle('Hex & Square Nuts');
- SetItem(RFlag[1],TRUE);
- SetItem(RFlag[2],TRUE);
- SetField(16,'3/4');
-
- 10:SelField(16);
- REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=True;
-
- IF Item=2 THEN
- BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
-
- IF (Item > 9) AND (Item < 13) THEN
- BEGIN
- SetRButton(2,Item);
- View:=Item-9;
- END;
-
- IF (Item >= 30) AND (Item <= 50) THEN
- BEGIN
- SetRButton(1,Item);
- Index:=Item-29;
- IF Index > 16 THEN
- BEGIN
- Inch:=FALSE;
- SetField(18, 'mm');
- END ELSE
- BEGIN
- Inch:=TRUE;
- SetField(18, 'in');
- END;
- END;
-
- UNTIL Done;
-
- IF Abort THEN GOTO 99;
- Size1:=GetField(16);
- Size:=Concat('''',Size1,'''');
- UprString(Size);
-
- {
- Determine the Type and Class of the nut.
- }
-
- j:=0;
- FOR n:=1 TO 5 DO
- BEGIN
- k:=n;
- j:=j + nClasses[n];
- IF Index <= j THEN
- BEGIN
- Type:=n;
- Class:=Index - j + nClasses[k];
- GOTO 20;
- END;
- END;
- GOTO 99;
-
- {
- Open the data file and get the dimensions of the nut.
- }
-
- 20:GetData;
- IF Abort THEN GOTO 99;
- IF SizeNotFound THEN
- BEGIN
- Done:=FALSE;
- GOTO 10;
- END;
-
- 99:ClrDialog;
- END;
-
- Procedure DrawTopView(Type : INTEGER);
- {
- This procedure draws the top view of the nut.
- }
- VAR
- r1, x1, y1, x2, y2, Theta, Theta1, Theta2, Theta3 : REAL;
-
- BEGIN
- Absolute;
- MoveTo(x0,y0);
- Relative;
- IF Type <> 3 THEN
- BEGIN
- Move(g/2,0);
- ClosePoly;
- Poly(0,0,a,#-120,a,#-180,a,#120,a,#60,a,#0);
- Absolute;
- MoveTo(x0,y0);
- Relative;
- IF (Type = 4) OR ((Type = 5)AND(Class = 5)) THEN
- BEGIN
- Theta1:=Rad2Deg(ArcSin(s/f));
- Theta:=30;
- REPEAT
- Arc(-f/2,f/2,f/2,-f/2,Theta+Theta1,60-2*Theta1);
- Theta:=Theta+60;
- UNTIL Theta > 360;
- END ELSE
- Arc(-f/2,f/2,f/2,-f/2,0,360);
- END
- ELSE BEGIN
- Rect(-f/2,f/2,f/2,-f/2);
- IF Class <> 3 THEN
- Arc(-f/2,f/2,f/2,-f/2,0,360)
- END;
-
- PushAttrs;
- PenSize(1);
- PenPat(-2);
- Arc(-d/2,d/2,d/2,-d/2,0,360);
- PopAttrs;
- Arc(-di/2,di/2,di/2,-di/2,0,360);
-
- IF (Type = 4) OR ((Type = 5)AND(Class = 5)) THEN
- BEGIN
- r1:=Sqrt((s/2)^2 + (f/2)^2);
- Theta2:=ArcSin(s/di);
- Theta3:=ArcTan(s/f);
- Theta:=0;
- Absolute;
- REPEAT
- x1:=di*Sin(Theta+Theta2)/2;
- y1:=di*Cos(Theta+Theta2)/2;
- x2:=r1*Sin(Theta+Theta3);
- y2:=r1*Cos(Theta+Theta3);
- MoveTo(x0-x1, y0-y1);
- LineTo(x0-x2, y0-y2);
- MoveTo(x0+x1, y0-y1);
- LineTo(x0+x2, y0-y2);
- Theta:=Theta + Pi/3;
- UNTIL Theta > 2*Pi;
- END;
- END;
-
- Procedure DrawFrontView(Type : INTEGER);
- {
- This procedure draws the front view of the nut.
- }
- LABEL 10, 20, 30;
-
- BEGIN
- Absolute;
- MoveTo(x0-g/2, y0+h);
- Relative;
-
- {
- Regular hex nuts.
- }
-
- IF (Type = 1) OR (Type = 2) OR ((Type = 5)AND(Class <> 5))THEN
- BEGIN
- Move(0, -e1);
- ClosePoly;
- BeginPoly;
- LineTo(0, 0);
- LineTo(m, e1);
- LineTo(f, 0);
- LineTo(m, -e1);
- LineTo(0, -c);
- IF e2 <> 0 THEN
- BEGIN
- LineTo(-m, -e2);
- LineTo(-f, 0);
- LineTo(-m, e2);
- END ELSE
- LineTo(-g, 0);
- EndPoly;
- Move(0, c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(b/2, e1);
- LineTo(b/2, -e1);
- CurveThrough(a/2, e1);
- LineTo(a/2, -e1);
- CurveThrough(b/2, e1);
- LineTo(b/2, -e1);
- EndPoly;
- IF e2 = 0 THEN GOTO 10;
- Move(-g, -c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(b/2, -e2);
- LineTo(b/2, e2);
- CurveThrough(a/2, -e2);
- LineTo(a/2, e2);
- CurveThrough(b/2,- e2);
- LineTo(b/2, e2);
- EndPoly;
- 10:Absolute;
- MoveTo(x0-a/2, y0+(h-e1));
- Relative;
- LineTo(0,- c);
- Move(a, 0);
- LineTo(0, c);
- END
-
- {
- Slotted nuts.
- }
-
- ELSE IF (Type = 4) OR ((Type = 5)AND(Class = 5)) THEN
- BEGIN
- Move(0, -e1);
- ClosePoly;
- BeginPoly;
- LineTo(0, 0);
- LineTo(m, e1);
- LineTo((f-s)/2, 0);
- ArcTo(0, -(h-t), s/2);
- ArcTo(s, 0, s/2);
- LineTo(0, (h-t));
- LineTo((f-s)/2, 0);
- LineTo(m, -e1);
- LineTo(0, -c);
- IF e2 <> 0 THEN
- BEGIN
- LineTo(-m, -e2);
- LineTo(-f, 0);
- LineTo(-m, e2);
- END ELSE
- LineTo(-g, 0);
- EndPoly;
-
- Move(0, c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough((b-s/2)/4, k3*k2*e1);
- LineTo((b-s/2)/4, (1-k3)*k2*e1);
- EndPoly;
-
- MoveTo(s/2, 0);
- BeginPoly;
- LineTo(0,0);
- CurveThrough((b-s/2)/4, -(1-k3)*k2*e1);
- LineTo((b-s/2)/4, -k3*k2*e1);
- CurveThrough((a-s)/4, k1*e1);
- LineTo((a-s)/4, (1-k1)*e1);
- EndPoly;
-
- MoveTo(s, 0);
- BeginPoly;
- LineTo(0, 0);
- CurveThrough((a-s)/4, -(1-k1)*e1);
- LineTo((a-s)/4, -k1*e1);
- CurveThrough((b-s/2)/4, k3*k2*e1);
- LineTo((b-s/2)/4, (1-k3)*k2*e1);
- EndPoly;
-
- MoveTo(s/2, 0);
- BeginPoly;
- LineTo(0,0);
- CurveThrough((b-s/2)/4, -(1-k3)*k2*e1);
- LineTo((b-s/2)/4, -k3*k2*e1);
- EndPoly;
-
- IF e2 = 0 THEN GOTO 10;
- Move(-g, -c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(b/2, -e2);
- LineTo(b/2, e2);
- CurveThrough(a/2, -e2);
- LineTo(a/2, e2);
- CurveThrough(b/2,- e2);
- LineTo(b/2, e2);
- EndPoly;
- 10:Absolute;
- MoveTo(x0-a/2, y0+(h-e1));
- Relative;
- LineTo(0,- c);
- Move(a, 0);
- LineTo(0, c);
-
- Absolute;
- MoveTo(x0 - (a+b+s/2)/2, y0+h);
- Relative;
- LineTo(0, -(h-t-s/2));
- MoveTo(s/4, 0);
- Arc(-s/4, s/2, s/4, -s/2, 180, 180);
- MoveTo(s/4, 0);
- LineTo(0, (h-t-s/2));
-
- Absolute;
- MoveTo(x0 + (a+b-s/2)/2, y0+h);
- Relative;
- LineTo(0, -(h-t-s/2));
- MoveTo(s/4, 0);
- Arc(-s/4, s/2, s/4, -s/2, 180, 180);
- MoveTo(s/4, 0);
- LineTo(0, (h-t-s/2));
- END
-
- {
- Square nuts.
- }
-
- ELSE BEGIN
- Move(0, -e1);
- IF Class = 3 THEN GOTO 20;
- ClosePoly;
- BeginPoly;
- LineTo(0, 0);
- LineTo(m, e1);
- LineTo(f, 0);
- LineTo(m, -e1);
- LineTo(0, -c);
- IF e2 <> 0 THEN
- BEGIN
- LineTo(-m, -e2);
- LineTo(-f, 0);
- LineTo(-m, e2);
- END ELSE
- LineTo(-g, 0);
- EndPoly;
- Move(0, c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(b/2, e1);
- LineTo(b/2, -e1);
- CurveThrough(b/2, e1);
- LineTo(b/2, -e1);
- EndPoly;
- IF e2 = 0 THEN GOTO 30;
- Move(-g, -c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(b/2, -e2);
- LineTo(b/2, e2);
- CurveThrough(b/2,- e2);
- LineTo(b/2, e2);
- EndPoly;
- GOTO 30;
- 20:Rect(0, 0, g, -h);
- 30:Absolute;
- MoveTo(x0-a/2, y0+(h-e1));
- Relative;
- LineTo(0,- c);
- END;
- END;
-
- Procedure DrawSideView(Type:INTEGER);
- {
- This procedure draws the side view of the nut.
- }
- LABEL 10, 20;
-
- BEGIN
- Absolute;
- MoveTo(x0-f/2, y0+h);
- Relative;
- Rect(0, 0, f, -h);
-
- {
- Regular hex nuts.
- }
-
- IF (Type = 1) OR (Type = 2) OR ((Type = 5)AND(Class <> 5)) THEN
- BEGIN
- Move(0, -e1);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(f/4, e1);
- LineTo(f/4, -e1);
- CurveThrough(f/4, e1);
- LineTo(f/4, -e1);
- EndPoly;
- IF e2 = 0 THEN GOTO 10;
- Move(-f, -c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(f/4, -e2);
- LineTo(f/4, e2);
- CurveThrough(f/4, -e2);
- LineTo(f/4, e2);
- EndPoly;
- 10:Absolute;
- MoveTo(x0, y0+(h-e1));
- Relative;
- LineTo(0,- c);
- END
-
- {
- Slotted hex nuts.
- }
-
- ELSE IF (Type = 4) OR ((Type = 5)AND(Class = 5)) THEN
- BEGIN
- MoveTo((f/2 - k4*s)/2, 0);
- ClosePoly;
- BeginPoly;
- LineTo(0, 0);
- LineTo(0, -(h-t-s/2));
- MoveTo(k4*s/2, 0);
- Arc(-k4*s/2, s/2, k4*s/2, -s/2, 180, 180);
- MoveTo(k4*s/2, 0);
- LineTo(0, (h-t-s/2));
- EndPoly;
-
- MoveTo((f/2 - k4*s), 0);
- BeginPoly;
- LineTo(0, 0);
- LineTo(0, -(h-t-s/2));
- MoveTo(k4*s/2, 0);
- Arc(-k4*s/2, s/2, k4*s/2, -s/2, 180, 180);
- MoveTo(k4*s/2, 0);
- LineTo(0, (h-t-s/2));
- EndPoly;
-
- Absolute;
- MoveTo((x0 - f/2), (y0 + h - e1));
- Relative;
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough((f/2 - k4*s)/4, k3*k2*e1);
- LineTo((f/2 - k4*s)/4, (1-k3)*k2*e1);
- EndPoly;
-
- Move(k4*S, 0);
- BeginPoly;
- LineTo(0,0);
- CurveThrough((f/2 - k4*s)/4, -(1-k3)*k2*e1);
- LineTo((f/2 - k4*s)/4, -k3*k2*e1);
- CurveThrough((f/2 - k4*s)/4, k3*k2*e1);
- LineTo((f/2 - k4*s)/4, (1-k3)*k2*e1);
- EndPoly;
-
- Move(k4*S, 0);
- BeginPoly;
- LineTo(0,0);
- CurveThrough((f/2 - k4*s)/4, -(1-k3)*k2*e1);
- LineTo((f/2 - k4*s)/4, -k3*k2*e1);
- EndPoly;
-
- IF e2 = 0 THEN GOTO 10;
- Move(-f, -c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(f/4, -e2);
- LineTo(f/4, e2);
- CurveThrough(f/4, -e2);
- LineTo(f/4, e2);
- EndPoly;
- 10:Absolute;
- MoveTo(x0, y0+(h-e1));
- Relative;
- LineTo(0,- c);
- END
-
- {
- Square nuts.
- }
-
- ELSE BEGIN;
- IF Class = 3 THEN GOTO 20;
- Move(0, -e1);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(f/2, e1);
- LineTo(f/2, -e1);
- EndPoly;
- IF e2 = 0 THEN GOTO 20;
- Move(-f, -c);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- CurveThrough(f/2, -e2);
- LineTo(f/2, e2);
- EndPoly;
- 20:END;
- END;
-
- {
- Main program.
- }
- BEGIN
- DselectAll;
- PushAttrs;
- NutDialog;
-
- {
- Set the number of classes for each type of nut.
- }
-
- nClasses[1]:=6;
- nClasses[2]:=4;
- nClasses[3]:=3;
- nClasses[4]:=3;
- nClasses[5]:=5;
-
- {
- Display the main dialog box and get the information.
- }
-
- SetCursor(ArrowC);
- GetInfo;
- IF Abort THEN GOTO 99;
-
- {
- Get the location of the nut.
- }
-
- GetPt(x0,y0);
-
- {
- Get units per inch and adjust variables accordingly.
- }
-
- GetUnits(UName,DA,Fmt,UPI,UM,UM2);
- IF Inch=TRUE THEN
- SF:=UPI
- ELSE
- SF:=UPI/25.4;
-
- d:=d*SF;
- f:=f*SF;
- h:=h*SF;
- t:=t*SF;
- s:=s*SF;
-
- {
- Calculate additional variables needed to draw nut.
- }
-
- IF Type <>3 THEN
- BEGIN
- a:=f*Tan(Pi/6);
- g:=f/Cos(Pi/6);
- b:=(g-a)/2;
- e1:=(g-f)*Tan(Deg2Rad(Alpha))/2;
- IF ((Type=1)AND((Class=4)OR(Class=5))) OR ((Type = 2)AND(Class>2)) THEN
- e2:=0
- ELSE
- e2:=e1;
- END ELSE
-
- BEGIN
- a:=0;
- g:=f/Cos(Pi/4);
- b:=(g-a)/2;
- IF Class <> 3 THEN
- e1:=(g-f)*Tan(Deg2Rad(Beta))/2
- ELSE
- e1:=0;
- e2:=e1;
- END;
-
- di:=dik*d;
- c:=h - (e1+e2);
- m:=(g-f)/2;
-
- {
- Draw nut.
- }
-
- IF View = 1 THEN
- DrawTopView(Type)
- ELSE IF View = 2 THEN
- DrawFrontView(Type)
- ELSE
- DrawSideView(Type);
- Group;
- PopAttrs;
-
- 99:END;
-
- Run(DrawNut);
-