
! script name: vdraftedit.d/centertext
! var_topic: center text in a dimension

!A
!A NAME:
!A
!A 	Center		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script centers text in a dimension.
!A
!B INSTRUCTIONS:
!B
!B 	PICK DIMENSION: Pick the dimension.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: center text ")

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

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

Nocalc=0
Calculate=1
Toggle_sw= 2
Turn_on=1


ActivateUndo
Element_loop:!
stat= SetInputFormat("n4","")
E1=PickEntity("PICK DIMENSION ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Element_loop
E2= ParentDimEnt(E1)
IF NOT ValidGeometry(E2) THEN Element_loop
IF NOT ValidDependency(E2) THEN Element_loop
Stat= EntityNameCheck(E2,Element$)

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

RecordFunctionOn
Stat= RecordDescr("TEXT: Centered")
Stat=EditDraftSetting(Element$,WsTextCentered,Turn_on,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
