
! script name: vdraftedit.d/dimtextsize
! var_topic: edit text size in a dimension

!A
!A NAME:
!A
!A 	Size		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script changes the text size in a dimension.
!A
!B INSTRUCTIONS:
!B
!B 	PICK DIMENSION TO BE CHANGED: Pick one of the dimension lines.
!B
!B 	TEXT HEIGHT: Enter the new text height. 	
!B
!B 	TEXT WIDTH: Enter the new text width.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: edit text size ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Element$[256]
DIM Height_var$[256]
DIM Width_var$[256]

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

ActivateUndo
Nocalc=0
Calculate=1

Text_height= GetDefault(WsTextHeight)
Text_width= GetDefault(WsTextWidth)

Text_size:stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Text_height)
Text_height= GetValue("INPUT TEXT HEIGHT ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_height_var= LastVariableInput(Height_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Text_width)
Text_width= GetValue("INPUT TEXT WIDTH ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_width_var= LastVariableInput(Width_var$)

Element_loop:!
stat= SetInputFormat("a1",",N,A,")
Element_loop:E1=PickEntity("PICK DIMENSION TO BE CHANGED, New size , All ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N"
	GOTO Text_size
CASE "A"
	DeActivateUndo
	RecordFunctionOn
	Stat= RecordDescr("TEXT: Size")
	IF No_height_var THEN
       		 V1= FreeParameter("Text height",Text_height)
	ELSE
       		 V1= FreeParameter("Text height",Height_var$)
	END IF
	IF No_width_var THEN
       		 V2= FreeParameter("Text width",Text_width)
	ELSE
       		 V2= FreeParameter("Text width",Width_var$)
	END IF
	Stat=EditDraftSetting(0,WsTextHeight,V1,Nocalc)
	Stat=EditDraftSetting(0,WsTextWidth,V2,Nocalc)
	Stat=EditDraftSetting(0,WsArrowHeight,V1,Nocalc)
	Stat=EditDraftSetting(0,WsArrowWidth,V2,Calculate)
	RecordFunctionOff
	CloseVarRecord
	GOTO Text_size
END SELECT

IF NOT ValidGeometry(E1) THEN Element_loop
E2= ParentDimEnt(E1)
IF NOT ValidDependency(E2) THEN Element_loop
Stat= EntityNameCheck(E2,Element$)


ActivateUndo
Stat= AdvanceUndoNumber("text size")
Stat= AddDimToUndo(WsUBModifyMode,Element$)

RecordFunctionOn
Stat= RecordDescr("TEXT: Size")
IF No_height_var THEN
        V1= FreeParameter("Text height",Text_height)
ELSE
        V1= FreeParameter("Text height",Height_var$)
END IF
IF No_width_var THEN
        V2= FreeParameter("Text width",Text_width)
ELSE
        V2= FreeParameter("Text width",Width_var$)
END IF
Stat=EditDraftSetting(Element$,WsTextHeight,V1,Nocalc)
Stat=EditDraftSetting(Element$,WsTextWidth,V2,Nocalc)
Stat=EditDraftSetting(Element$,WsArrowHeight,V1,Nocalc)
Stat=EditDraftSetting(Element$,WsArrowWidth,V2,Calculate)
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
