
! script name: copy.d/layercopycont
! topic: Layer copy group

!A
!A NAME:
!A
!A 	Layer Copy Group
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities or a single entity to be
!A 	copied to a layer. 
!A
!B INSTRUCTIONS:
!B
!B 	PICK GROUP TO BE COPIED: Pick an element on the group to be copied.
!B
!B 	LAYER NUMBER: Enter the value for the layer where the copy is placed.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: layer copy group ")

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

Layer=InputLayer("LAYER NUMBER ")
IF ExitScript(Destination$) THEN Leave

Pm=PointXYZ(0,0,0)
T1=AngleTransform(Pm,0,0,0,WsWorkplaneVals)

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

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

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
