
! script name: copy.d/2dcopybox
! topic: 2D copy boxed group by reference points

!A
!A NAME:
!A
!A      2D Absolute 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 	REFERENCE POINT ABS X,Y: Enter the X,Y coordinates of the point
!B 		to be used as the reference for the copy.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	DESTINATION POINT ABS X,Y: Enter the X,Y coordinates of the point
!B 		to be used as the reference for the copied elements.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 2d absolute copy box ")

DIM Answer$[256]
DIM Destination$[256]
DIM Which$[16]
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

Pt=XyzInput("REFERENCE POINT ",WsXyOnly)
IF ExitScript(Destination$) THEN Leave

Which$= "FIRST"

Dest_pt:!

Pe=XyzInput(Which$&" DESTINATION POINT",WsXyInput)
IF ExitScript(Destination$) THEN Leave

Move_vector= VectorTwoPts(Pt,Pe)
G1= VectorCopyGroup(Group,Move_vector)

ActivateUndo
Stat= AdvanceUndoNumber("copy")
Stat= AddGroupToUndo(WsUBCreateMode,G1,2,WsTrue)
Stat= DeleteEntity(G1)
Stat= DeleteEntity(Pe,WsTrue)
Stat= DeleteEntity(Move_vector)

Which$= "NEXT"
GOTO Dest_pt

Stat= DeleteEntity(Group)
Stat= DeleteEntity(G1)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Pt)
Stat= DeleteEntity(Move_vector)

PlotAll
GOTO Start

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

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