
! script name: parasolids.d/pklayerent
! solids: assign layer to a solid entity

!A
!A NAME:
!A
!A 	Layer Solid Entity
!A
!A DESCRIPTION:
!A
!A 	This script allows a single element to be assigned a layer.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ELEMENT TO BE ASSIGNED LAYER: Pick the element.
!B
!B OPTIONS:
!B
!B	Faces and edges may now be assigned a layer. The standard show by
!B	layer will not separate layered faces from the rest of a body.
!B	Only bodies can be shown by layer from the standard controls.
!B	A special viewing mode for viewing layered (or colored) faces
!B	is available on the OpenGL menu in solid modeling. This mode
!B	shows selected faces shaded with the rest of the body a wire frame.
!B
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: layer solid entity ")

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

Pick_loop:!
Stat=SetInputFormat("n4","")
IF OSystemId= 2 THEN
E1=WPKPickEntity("PICK ELEMENT TO BE ASSIGNED LAYER")
ELSE
E1=WPKPickEntity("PICK ELEMENT TO BE ASSIGNED LAYER  "&VAL$(Layer))
END IF
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_loop

Layer=CurrentLayer
Stat= WPKLayerEntity(E1,Layer)

ActivateUndo
Stat= AdvanceUndoNumber("layer solid entity")
Stat= AddItemToUndo(WsUBPKSessionMark)

GOTO Pick_loop

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