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

!A
!A NAME:
!A
!A      2D Absolute Copy Group
!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 	PICK GROUP TO BE COPIED: Pick an element on the group to be copied.
!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 group ")

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

Start: !
ActivateUndo

stat= SetInputFormat("n4","")

C1=PickGroupEnt("PICK GROUP TO BE COPIED ")
IF ExitScript(Destination$) THEN Leave

IF NOT ValidGeometry(C1) THEN Start
Stat=Highlight(C1,WsPickPen,WsDirArrowOff)

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

Xs=XPointValue(Pt)
Ys=YPointValue(Pt)

Xe=XPointValue(Pe)
Ye=YPointValue(Pe)

Xmove=Xe-Xs
Ymove=Ye-Ys
Zmove= 0

Pm=PointXYZ(Xmove,Ymove,Zmove)
T1=AngleTransform(Pm,0,0,0,WsWorkplaneVals)

PlotOff
C2= CopyGroup(C1)
PlotOn
Stat=TransGroupTrans(C2,T1,0,1)
Stat=AutoNumber(C2)
IF ValidGeometry(Pm) THEN Stat= DeleteEntity(Pm)
IF ValidGeometry(Pe) THEN Stat= DeleteEntity(Pe)

ActivateUndo
Stat= AdvanceUndoNumber("copy")
Stat= AddGroupToUndo(WsUBCreateMode,C2,1,WsTrue)

Which$= "NEXT"
GOTO Dest_pt

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

PlotAll
GOTO Start

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


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