
! script name: draft.d/setdrafttol
! var_topic: set drafting tolerance data

!A
!A NAME:
!A
!A 	Dimension Tolerances
!A
!A DESCRIPTION:
!A
!A 	This script sets drafting tolerance data.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT OPTION: The TOLERANCE FORMATS selection box will automatically
!B 		appear to allow a selection.  The following are the present
!B 		choices:
!B
!B 			NO TOLERANCE
!B 			ONE LINE LIMIT DIMS
!B 			OVER UNDER LIMIT DIMS
!B 			OVER UNDER TOLERANCES
!B 			UNIFORM TOLERANCE
!B			ONE LINE INCH METRIC
!B			ONE LINE INCH METRIC BRACKETS
!B			OVER UNDER INCH METRIC
!B			OVER UNDER INCH METRIC BRACKETS
!B
!B 		These selections change the way dimensions appear.
!B
!B 		NO TOLERANCE - This turns off the switch to include tolerances
!B 		        in the dimension box.
!B 		ONE LINE LIMIT DIMS - This will put the available range on a
!B 		        single line.
!B 		OVER UNDER LIMIT DIMS - This places the upper range of the
!B 		        number over the lower range of the number.
!B 		OVER UNDER TOLERANCES - This places the positive tolerance
!B 		        above the negative tolerance, next to the dimension.
!B 		UNIFORM TOLERANCE: The positive tolerance will be used for the
!B 		        upper and lower tolerance range.
!B		ONE LINE INCH METRIC: Inch/Metric dimensions on one line.
!B		ONE LINE INCH METRIC BRACKETS: Inch/Metric dimensions 
!B				on one line. Other dim bracketed.
!B		OVER UNDER INCH METRIC Inch over Metric dimensions.
!B		OVER UNDER INCH METRIC BRACKETS Inch over Metric dimensions.
!B				Other dim bracketed.
!B
!B 	POSITIVE TOLERANCE: Enter the allowable positive tolerance to be used
!B 		in the labeling of dimensions.
!B
!B 	NEGATIVE TOLERANCE: Enter the allowable negative tolerance to be used
!B 		in the labeling of dimensions.
!B
!C NOTE: 
!C
!C 	+/+ and -/- TOLERANCES.
!C
!C 	Normally both positive and negative tolerances are answered with
!C 	positive answers and the signs are added automatically.
!C
!C 	Answering a negative number for a tolerance will reverse its sign.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: dimension tolerances ")

DIM Answer$[256]
DIM Destination$[256]
DIM Dim_type$[256]
DIM Namelist$[2024]
DIM Title$[256]
DIM Label$[256]
DIM Plus_tol$[256]
DIM Minus_tol$[256]

Var_object= CheckVarObject
IF ExitScript(Destination$) THEN Leave
DEG


DeActivateUndo
Dim_loop:!

Title$="TOLERANCE FORMATS" 
Label$="FORMAT SELECTED"
Namelist$="NO TOLERANCE,"
Namelist$=Namelist$&"ONE LINE LIMIT DIMS,"
Namelist$=Namelist$&"OVER UNDER LIMIT DIMS,"
Namelist$=Namelist$&"OVER UNDER TOLERANCES,"
Namelist$=Namelist$&"UNIFORM TOLERANCE,"
Namelist$=Namelist$&"ONE LINE INCH METRIC,"
Namelist$=Namelist$&"ONE LINE INCH METRIC BRACKETS,"
Namelist$=Namelist$&"OVER UNDER INCH METRIC,"
Namelist$=Namelist$&"OVER UNDER INCH METRIC BRACKETS,"

Stat=GeneralListBox(Title$,Label$,Namelist$)
Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT OPTION",Answer$)
IF (ExitScript(Destination$)) THEN Leave

LowerSelectBox
stat= SetInputFormat("n4","")

SELECT Answer$
CASE "NO TOLERANCE"
	Tol_type= 1
CASE "ONE LINE LIMIT DIMS"
	Tol_type= 4
CASE "OVER UNDER LIMIT DIMS"
	Tol_type= 2
CASE "OVER UNDER TOLERANCES"
	Tol_type= 3
CASE "UNIFORM TOLERANCE"
	Tol_type= 5
CASE "ONE LINE INCH/METRIC"
	Tol_type= 7
CASE "ONE LINE INCH METRIC BRACKETS"
	Tol_type= 8
CASE "OVER UNDER INCH METRIC"
	Tol_type= 9
CASE "OVER UNDER INCH METRIC BRACKETS"
	Tol_type= 10
CASE "CANCEL"
        LowerSelectBox
         LOAD "typecontrol"
END SELECT

SELECT Tol_type
CASE 2,3,4
        stat= SetInputFormat("n4=","")
        stat= SetEqualsValue(0)
        Plus_tol=GetValue("POSITIVE TOLERANCE",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
	No_plus_var= LastVariableInput(Plus_tol$)

        stat= SetEqualsValue(Plus_tol)
        Minus_tol=GetValue("NEGATIVE TOLERANCE",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
	No_minus_var= LastVariableInput(Minus_tol$)
CASE 5
        stat= SetInputFormat("n4=","")
        stat= SetEqualsValue(0)
        Plus_tol=GetValue("TOLERANCE",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
	No_plus_var= LastVariableInput(Plus_tol$)
	No_minus_var= LastVariableInput(Minus_tol$)
        Minus_tol= Plus_tol
CASE ELSE
	No_plus_var=1
	No_minus_var=1
        Minus_tol=0
        Plus_tol=0
END SELECT

RecordFunctionOn
Stat= RecordDescr("DIM: Set tolerance dimension ")
V1= FreeParameter("Tolerance type",Tol_type)
IF No_plus_var THEN
        V2= FreeParameter("Plus Tolerance",Plus_tol)
ELSE
        V2= FreeParameter("Plus Tolerance",Plus_tol$)
END IF
IF No_minus_var THEN
        V3= FreeParameter("Minus Tolerance",Minus_tol)
ELSE
        V3= FreeParameter("Minus Tolerance",Minus_tol$)
END IF
stat= SetDimTolerance(V1,V2,V3)
RecordFunctionOff
CloseVarRecord


Leave:!

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
