
! script name: copy.d/3dinccopybox
! topic: 3D copy boxed group by incremental moves

!A
!A NAME:
!A
!A      3D Incremental Copy Box
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities or a single entity to be
!A 	copied and the option of the original being deleted.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements are to be
!B 		copied in.
!B
!B	X,Y,Z AXIS INCREMENT: Value in X,Y,Z to shift entities.
!B
!B 	NUMBER OF TIMES: Enter the number of times the copy process
!B 		should be repeated.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 3d incremental copy box ")

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

Start: !
ActivateUndo

stat= SetInputFormat("n4","")

Group=CreateGroup("TEMP")


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

IF NOT ValidGeometry(Group) THEN
        GOTO Start
ELSE
        IF NOT GroupCount(Group) THEN Start
END IF


Xmove=GetValue("X INCREMENT ")
IF ExitScript(Destination$) THEN Leave

Ymove=GetValue("Y INCREMENT ")
IF ExitScript(Destination$) THEN Leave

Zmove=GetValue("Z INCREMENT ")
IF ExitScript(Destination$) THEN Leave


Stat=SetInputFormat("n0=","")
Stat=SetEqualsValue(1)
Number=GetValue("NUMBER OF TIMES",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Number=0 THEN Start

Move_vector= PointXYZ(Xmove,Ymove,Zmove)
G1= VectorCopyGroup(Group,Move_vector,Number)

Stat= DeleteEntity(Group)
Stat= DeleteEntity(Move_vector)

ActivateUndo
Stat= AdvanceUndoNumber("copy")
Stat= AddGroupToUndo(WsUBCreateMode,G1,2,WsTrue)
IF Number> 1 THEN
        FOR I= 1 TO NUMBER
                G2= GroupElement(G1,I)
                Stat= DeleteEntity(G2)
        NEXT I
END IF
Stat= DeleteEntity(G1)

PlotAll
GOTO Start

Leave: !
ActivateUndo
stat= SetInputFormat("n4","")
Stat= DeleteEntity(G1)
Stat= DeleteEntity(Group)
Stat= DeleteEntity(Move_vector)

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