
! script name: parasolids.d/pklayerbody
! solids: assign layer to a solid body

!A
!A NAME:
!A
!A 	Layer Body
!A
!A DESCRIPTION:
!A
!A 	This script allows a solid body to be assigned a layer. 
!A	Both faces and edges within the body are assigned the same layer.
!A
!B INSTRUCTIONS:
!B
!B 	PICK BODY TO BE LAYERED: Pick the body.
!B
!B NOTES:
!B 
!B	Show by layer will show only bodies on the selected layers. 
!B	Faces and edges may now be placed on layers. The standard show
!B	by layer will not separate faces and edges from a body.
!B
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: color solid body ")

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

Stat= GLPlotOn
Pick_loop:!
Stat=SetInputFormat("n4","")

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

Pkbody= WPKParentBody(E1)
Layer=CurrentLayer
Stat= WPKLayerEntity(Pkbody,Layer)

ActivateUndo
Stat= AdvanceUndoNumber("layer body")
Stat= AddItemToUndo(WsUBPKSessionMark)

GOTO Pick_loop

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