
! script name: layers.d/layergroup
! topic: layer group of elements in box

!A
!A NAME:
!A
!A 	Layer in Box
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of elements within a box to be layered.
!A
!B INSTRUCTIONS:
!B
!B 	LAYER NUMBER,   current layer= # : Enter the layer number that will
!B 		be assigned to the elements selected.
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that the elements are in.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: layer in box ")

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

ActivateUndo
Layer=CurrentLayer

Ask_layer=1
IF ARGC> 1 THEN Ask_layer=0

IF Ask_layer THEN
        Stat=SetInputFormat("n0=","")
        Stat= SetEqualsValue(Layer)
        Layer=InputLayer("LAYER NUMBER ")
        IF (ExitScript(Destination$)) THEN Leave
        Stat= SetCurrentLayer(Layer)
END IF

Group_loop:!
Group=CreateGroup("TEMPGROUP")

Vnum= LastPickView
Stat=PickBox(Group,Vnum,WsPickPen)
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Stat= AdvanceUndoNumber("layer group")
Stat= AddGroupToUndo(WsUBModifyMode,Group,0,WsFalse)

Stat=SetLayer(Group)
Stat=DeleteEntity(Group)

GOTO Group_loop

Leave:!
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Group)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


