
! script name: pkattributes.d/vpklayerent
! var_solids: assign layer to a solid entity

!A
!A NAME:
!A
!A 	Layer Entity	VARIATIONAL
!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]
DIM Element$[256]

ActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

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:!
Layer=CurrentLayer
Stat=SetInputFormat("n4","")
E1=WPKPickEntity("PICK ELEMENT TO BE ASSIGNED LAYER  "&VAL$(Layer))
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_loop
Stat= EntityNameCheck(E1,Element$)

Layer=CurrentLayer

WPKClearErrorFlag
RecordFunctionOn
Stat= RecordDescr("ENTITY: layer")
V1= FreeParameter("Layer",Layer)
Stat= WPKLayerEntity(Element$,V1)
PlotOn
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("layer entity")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck
GOTO Pick_loop

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