
! script name: copy.d/3dcopymulti
! topic: 3D copy picked group by reference points

!A
!A NAME:
!A
!A      3D Absolute Copy Picked 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 ELEMENTS TO BE COPIED, PROCEED: Pick one of the elements to be
!B 		copied.  The question will repeat until "PROCEED" is answered.
!B 		All elements picked will then be copied.
!B
!B 	REFERENCE POINT ABS X,Y,Z: Enter the X,Y,Z 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,Z: Enter the X,Y,Z coordinates of the point
!B 		to be used as the reference for the copied elements.
!B 		NOTE: See XYZ INPUT OPTIONS.
!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 absolute copy picked group ")

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

Start: !
ActivateUndo

stat= SetInputFormat("n4","")

Group=CreateGroup("TEMP")
Extras$= ""

LOOP
        stat= SetInputFormat("a1",",P,B,")
	E1= PickEntity("PICK ELEMENTS TO BE COPIED"&Extras$,Answer$)
        IF ExitScript(Destination$) THEN Leave
	Stat=SetInputFormat("n4"," ")
        EXIT IF Answer$= "P"
	IF Answer$="B" THEN
		Num1=GroupCount(Group)
		E1=GroupElement(Group,Num1)
		IF Num1 THEN Stat= RemoveFromGrp(Group,Num1)
		Stat= PlotEntity(E1)
		IF Num1=1 THEN Extras$= ""
	ELSE
		IF ValidGeometry(E1) THEN
			N1= ElementGrpNum(Group,E1)
			IF NOT N1 THEN Stat=AddToGroup(Group,E1)
			Extras$=", Backup , Proceed "
		END IF
	END IF

END LOOP

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


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

Pe=XyzInput("DESTINATION POINT",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

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

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

Xmove=Xe-Xs
Ymove=Ye-Ys
Zmove=Ze-Zs

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

ActivateUndo
Stat= AdvanceUndoNumber("copy")
FOR I= 1 TO Number 
Pm=PointXYZ(Xmove*I,Ymove*I,Zmove*I)
T1=AngleTransform(Pm,0,0,0,WsWorkplaneVals)

G1=TransformGroup(Group,T1,"TEMP1")
Stat= AddGroupToUndo(WsUBCreateMode,G1,2,WsTrue)
Stat=DeleteEntity(G1)
IF ValidGeometry(Pm) THEN Stat= DeleteEntity(Pm)

NEXT I

Stat= DeleteEntity(Pt)
Stat= DeleteEntity(Pe)
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
