
! script name: vmove.d/zmovebox
! var_topic: Z move entities in a box by incremental moves

!A
!A NAME:
!A
!A 	Z Only		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows entities in a box to be moved in Z.
!A
!B INSTRUCTIONS:
!B
!B 	Z INCREMENT: Enter the value in Z to shift entities.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: Z move contour box ")

DIM Answer$[256]
DIM Destination$[256]
DIM Element$[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=SetPickMask(WsPickAll)
Active_workplane=0
Work=CurrentWorkplane
IF ValidGeometry(Work) THEN Active_workplane=1

stat= SetInputFormat("n4","")
Group1=CreateGroup("TEMP")

Vnum= LastPickView
Stat=PickBox(Group1,Vnum,WsPickPen)
IF ExitScript(Destination$) THEN Leave

IF NOT ValidGeometry(Group1) THEN
        GOTO Start
ELSE
        Group2=CreateGroup("TEMP")
        Num_elements= GroupCount(Group1)
        FOR I=1 TO Num_elements
                E1= GroupElement(Group1,I)
                IF ValidGeometry(E1) THEN
                   IF IsEntityDependent(E1)= WsTrue THEN
                        Stat= EntityNameCheck(E1,Element$)
                        IF ValidDependency(E1,0) THEN
                            Stat= AddToGroup(Group2,Element$)
                        END IF
                   END IF
                END IF
        NEXT I
        Stat= DeleteEntity(Group1)
        Group1= Group2
        IF NOT GroupCount(Group1) THEN
                Stat= DeleteEntity(Group1)
                GOTO Start
        END IF
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(Group1)
Make_record:!
Stat= SetSelectedFlag(Group1,WsFalse)

ActivateUndo
Stat= AdvanceUndoNumber("move entities")
Stat= AddGroupToUndo(WsUBModifyMode,Group1,0,WsTrue)

Num_elements= GroupCount(Group1)
RecordFunctionOn
Stat= RecordDescr("MOVE: 2d incremental  move entities")
Cgroup= CreateGroup("Picked Entities")
FOR I=1 TO Num_elements
RecordFunctionOff
        E1= GroupElement(Group1,I)
        IF ValidGeometry(E1) THEN
              Stat= EntityNameCheck(E1,Element$)
              RecordFunctionOn
              Stat= AddToGroup(Cgroup,Element$)
              RecordFunctionOff
        END IF
NEXT I
RecordFunctionOn
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(Cgroup,Trans,0,1)
Stat= Unlink(Cgroup)
Stat= DeleteEntityList(Cgroup,Move_vector)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Group1)
Stat= DeleteEntity(Group1)
GOTO Start

Leave: !
stat= SetInputFormat("n4","")
Stat= DeleteEntity(Group1)


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

