
! script name: vdraftedit.d/gchdimloc
! var_topic: edit dim text location

!A
!A NAME:
!A
!A 	Graphical	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows dimensions to be edited.
!A
!B INSTRUCTIONS:
!B
!B 	PICK DIMENSION TO BE CHANGED : Pick one of the dimension lines
!B
!B 	INPUT NEW ABS X,Y: Enter the X,Y coordinates of the new point
!B 		location.  NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

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

DIM Answer$[256]
DIM Destination$[256]
DIM Element$[256]
DIM Point$[256]
DEG

Start:!
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
No_calc=0
Turn_off=0

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

Element_loop:E1=PickEntity("PICK ITEM TO BE CHANGED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Element_loop
E2= ParentDimEnt(E1)
IF NOT ValidDependency(E2) THEN Element_loop
Stat= EntityNameCheck(E2,Element$)
Which_end= ComDimTextEnd(E2)

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

Stat=EditDraftSetting(E2,WsTextCentered,Turn_off,No_calc)
Stat= DynamicDimEdit(Vnum,E2,Which_end,0,WsTrue,WsFalse)
IF (ExitScript(Destination$)) THEN 
UndoLastAction
ActivateUndo
GOTO Leave
END IF

PlotOff
SELECT Which_end
CASE WsStart
	T= 0.0
CASE WsMiddle
	T= 0.51
CASE WsEnd
	T= 1.00
CASE ELSE
	T= 0.51
END SELECT
Ps= ParameterPt(E2,0.0)
Ploc= ParameterPt(E2,T)
Stat= DimTextFlagStr(E2,Textflags$)
P1= SubtractVectors(Ploc,Ps)
Stat= XYZPointValues(P1,X1,Y1,Z1)
Stat=DeleteEntityList(P1,Ploc,Ps)
PlotOn

RecordFunctionOn
Stat= RecordDescr("DIMENSION: Change point")
Stat=EditDraftSetting(Element$,WsTextCentered,Turn_off,No_calc)
Ps= ParameterPt(Element$,0.0)
V1= FreeParameter("Xloc",X1)
V2= FreeParameter("Yloc",Y1)
Pt= PtIncrXyz(Ps,V1,V2,Z1)
Stat= ChangeComDimPt(Element$,Pt,Which_end,Textflags$)
Stat= DeleteEntityList(Pt,Ps)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Element_loop

Leave:!
Stat=DeleteEntityList(P1,Ploc,Ps)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
