
! script name: layers.d/setentlayer
! topic: assign single element to layer

!A
!A NAME:
!A
!A 	Assign Layer
!A
!A DESCRIPTION:
!A
!A 	This script allows a single element to be assigned to a layer.
!A
!B INSTRUCTIONS:
!B
!B 	LAYER NUMBER,   current layer= # : Enter the layer number to
!B 		be assigned to the element selected.
!B
!B 	PICK ELEMENT TO BE ASSIGNED LAYER # : Pick the element to be
!B 		assigned to the layer.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: assign layer ")

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

Ploop:!

IF OSystemId= 2 THEN
E1=PickEntity("PICK ELEMENT TO BE ASSIGNED LAYER")
ELSE
E1=PickEntity("PICK ELEMENT TO BE ASSIGNED LAYER  "&VAL$(Layer))
END IF
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Stat= AdvanceUndoNumber("set layer")
Stat= AddItemToUndo(WsUBModifyMode,E1)

Stat=SetLayer(E1)
IF WPKIsEntity(E1) THEN
	Stat= AddItemToUndo(WsUBPKSessionMark)
END IF


GOTO Ploop

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