
! script name: copy.d/copygrppic
! topic: Sample - move group of entities

!A
!A NAME:
!A
!A 	MOVE BY POINTS
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities to be moved.
!A
!B INSTRUCTIONS:
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that the elements
!B 		will be moved in.
!B
!B 	REFERENCE POINT ON ORIGINAL ABS X,Y,Z: Enter the X,Y,Z coordinates
!B 		of the point to be used as the reference for the move.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	DESTINATION POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the
!B 		destination point, which is used as the reference point
!B 		of the moved version and corresponds to the original
!B 		reference point.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: move by points ")

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

stat= SetInputFormat("n4","")
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

Group=CreateGroup("TEMP")

Start: !
ActivateUndo

Highlight_color= 2


Grp1=PickGroupEnt("PICK GROUP TO BE COPIED")
IF (ExitScript(Destination$)) THEN Leave
Stat=AddToGroup(Group,Grp1)
Stat=Highlight(Group,Highlight_color,0)


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

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

StdWorkplane

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

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

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

Pr=PointXYZ(Xmove,Ymove,Zmove)
T1=AngleTransform(Pr,0,0,0)
G1=TransformGroup(Group,T1,"TEMP1")
ActivateUndo
Stat= AdvanceUndoNumber("copy")
Stat= AddGroupToUndo(WsUBCreateMode,G1,2,WsTrue)
Stat=DeleteEntity(G1)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(Pr)
Stat=DeleteEntity(Pe)

IF Active_workplane THEN
	Stat=SetWorkplane(Work)
END IF

PlotAll
goto move_group

Leave:!
ActivateUndo
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pr)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(Group)
Stat=DeleteEntity(G1)
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF

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

