
! script name: geomtol.d/perptolbox
! topic: perpendicularity feature box

!A
!A NAME:
!A
!A 	Perpendicularity
!A
!A DESCRIPTION:
!A
!A 	This script makes a perpendicularity feature box.
!A
!A~ image location - images/perptolbox.gif
!A
!B INSTRUCTIONS:
!B
!B 	PERPENDICULARITY TOLERANCE: Enter the perpendicularity tolerance to
!B 		be entered in the feature box, for drafting purposes only.
!B
!# see also - geomtol.d/geominfo.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: perpendicularity ")

DIM Answer$[256]
DIM Destination$[256]
DIM A$[256]
DIM Toler$[256]
DIM Datum1$[30]
DIM Datum2$[30]
DIM Datum3$[30]
DIM Symbol$[30]
DIM Material$[30]
DIM Point$[256]
DIM Name$[256]
DEG


ActivateUndo
Nsym= 144
Dynamic_position=1


Units= CurrentUnits
Tol= 0.005
IF Units= WsMetric THEN Tol= 0.01

Text_loop:!
Symbol$= CHR$(Nsym)

Stat= SetEqualsValue(Tol)
Stat=SetInputFormat("n4=","")
Tol= GetValue("PERPENDICULARITY TOLERANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetInputFormat("a3",",LMC,MMC,RFS,N,")
stat= GetValue("MATERIAL CONDITION  LMC , MMC , RFS , None ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N", "None", "NONE"
        Material$= ""
CASE  "RFS"
        Material$= CHR$(138)
CASE  "LMC"
        Material$= CHR$(137)
CASE  "MMC"
        Material$= CHR$(136)
END SELECT
Toler$= VAL$(Tol)&" "&Material$


Stat=SetInputFormat("a99","")
stat= GetValue("DATUM 1  A B C D E F G ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,A$)
Stat= ReplaceString(A$,"\n",CHR$(10),Answer$)
Datum1$= UPC$(Answer$)

Stat=SetInputFormat("a99","")
stat= GetValue("DATUM 2  A B C D E F G ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,A$)
Stat= ReplaceString(A$,"\n",CHR$(10),Answer$)
Datum2$= UPC$(Answer$)

Stat=SetInputFormat("a99","")
stat= GetValue("DATUM 3  A B C D E F G ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,A$)
Stat= ReplaceString(A$,"\n",CHR$(10),Answer$)
Datum3$= UPC$(Answer$)

IF Dynamic_position THEN
	Pc= PointXYZ(0,0,0)
ELSE
	Stat=SetInputFormat("n4","")
	Pc=XyzInput("INPUT",WsXyzInput)
	IF (ExitScript(Destination$)) THEN Leave
END IF

Make_box:!
E1= FeatureControlBox(Pc,Tableorig,Symbol$,Toler$,Datum1$,Datum2$,Datum3$)
Stat=DeleteEntity(Pc)

IF Dynamic_position THEN
	Which_end=WsEnd
	Vnum= LastPickView
	Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK LOCATION")
	IF (ExitScript(Destination$)) THEN 
		Stat= DeleteEntity(E1)
		GOTO Leave
	END IF
END IF


ActivateUndo
Stat= AdvanceUndoNumber("feature box")
Stat= AddDimToUndo(WsUBCreateMode,E1)

Leave:!
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Text_loop
        IF Destination$= "BACKUP" THEN Text_loop
	 LOAD Destination$
END IF
END
