
! script name: draftedit.d/editdrafttol
! topic: edit drafting tolerance data

!A
!A NAME:
!A
!A 	Edit Dimension Tolerances
!A
!A DESCRIPTION:
!A
!A 	This script edit 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 		The Present choices are:
!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 NOTES:
!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: edit dimension tolerances ")

DIM Answer$[256]
DIM Destination$[256]
DIM Dim_type$[256]
DIM Namelist$[1024]
DIM Title$[256]
DIM Label$[256]
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

	stat= SetEqualsValue(Plus_tol)
	Minus_tol=GetValue("NEGATIVE TOLERANCE",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
CASE 5
	stat= SetInputFormat("n4=","")
	stat= SetEqualsValue(0)
	Plus_tol=GetValue("TOLERANCE",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	Minus_tol= Plus_tol
CASE 0,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 ValidGeometry(E2) THEN Element_loop

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

stat= EditDimTolerance(E2,Tol_type,Plus_tol,Minus_tol)

GOTO Element_loop


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

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