
! script name: vmove.d/zmovecont
! var_topic: Z move contour by incremental moves

!A
!A NAME:
!A
!A 	Z Only		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be moved incrementally in Z only.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE COPIED: Pick the contour to be moved.
!B
!B 	Z INCREMENT: Enter the value in Z to shift entities.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: Z Only")

DIM Answer$[256]
DIM Destination$[256]
DIM Contour$[256]
DIM Name$[256]
DIM X_var$[256]
DIM Y_var$[256]
DIM Z_var$[256]
DEG


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
Highlight_color= 3
Start: !
ActivateUndo
Stat= SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR TO BE MOVED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Start
IF IsEntityDependent(Contour)= WsFalse THEN
        stat= SetInputFormat("a99","")
        Stat= GetValue("NOT A VARIATIONAL CONTOUR, Proceed ",Answer$)
        IF ExitScript(Destination$) THEN Leave
        GOTO Start
END IF
Stat= EntityNameCheck(Contour,Contour$)
Stat=Highlight(Contour,Highlight_color,WsDirArrowOff)
IF NOT ValidGeometry(Contour) THEN
        GOTO Start
ELSE
        IF NOT GroupCount(Contour) THEN Start
END IF

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Zmove)
Zmove=GetValue("Z INCREMENT ")
IF ExitScript(Destination$) THEN Leave
No_z_var= LastVariableInput(Z_var$)

Xmove=0
Ymove=0

Stat= EraseEntity(Contour)

ActivateUndo
Stat= AdvanceUndoNumber("move contour")
Stat= AddGroupToUndo(WsUBModifyMode,Contour,1,WsTrue)

RecordFunctionOn
Stat= RecordDescr("MOVE: 3d move contour")
Stat= NullReference(Contour$)
IF No_z_var THEN
	V1= FreeParameter("Zmove",Zmove)
	Move_vector= PointXYZ(Xmove,Ymove,V1)
ELSE
	Move_vector= PointXYZ(Xmove,Ymove,Z_var$)
END IF
Trans=AngleTransform(Move_vector,0,0,0,WsWorkplaneVals)
Stat=TransGroupTrans(Contour$,Trans,0,1)
Stat= DeleteEntity(Move_vector)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start

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

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



