
! script name: vdraftedit.d/editdrafttol
! var_topic: edit drafting tolerance data

!A
!A NAME:
!A
!A 	Tolerances	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows the dimension tolerances to be edited.
!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 and these selections change the way dimensions appear:
!B
!B 		NO TOLERANCE - This turns off the switch to include tolerances in the dimension box.
!B 		ONE LINE LIMIT DIMS - This will put the available range on a single line.
!B 		OVER UNDER LIMIT DIMS - This places the upper range of the number over the lower range of the number.
!B 		OVER UNDER TOLERANCES - This places the positive tolerance above the negative tolerance, next to the dimension.
!B 		UNIFORM TOLERANCE: The positive tolerance will be used for the 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 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.  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

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

DIM Answer$[256]
DIM Destination$[256]
DIM Dim_type$[256]
DIM Namelist$[2048]
DIM Title$[256]
DIM Label$[256]
DIM Name$[256]
DIM Element$[256]
DIM Plus_tol$$[256]
DIM Minus_tol$$[256]

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


ActivateUndo
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
LowerSelectBox

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$)
        Minus_tol= Plus_tol
        No_minus_var=1
CASE ELSE
        No_plus_var=1
        No_minus_var=1
        Minus_tol=0
        Plus_tol=0
END SELECT


Element_loop:!
stat= SetInputFormat("a1",",N,")
E1=PickEntity("PICK DIMENSION TO BE CHANGED, New tolerance ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="N" THEN Dim_loop
IF NOT ValidGeometry(E1) THEN Element_loop
E2= ParentDimEnt(E1)
IF NOT ValidDependency(E2) THEN Element_loop
Stat= EntityNameCheck(E2,Element$)

ActivateUndo
Stat= AdvanceUndoNumber("dim tolerance")
Stat= AddDimToUndo(WsUBModifyMode,Element$)

RecordFunctionOn
Stat= RecordDescr("DIMENSION: Add tolerance")
V1= FreeParameter("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= EditDimTolerance(Element$,V1,V2,V3)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Element_loop


Leave:!
stat= SetInputFormat("n4","")

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