
! script name: pktransform.d/pkcopytolayer
! solids: copy a body to a layer

!A
!A NAME:
!A
!A 	Copy To a Layer
!A
!A DESCRIPTION:
!A
!A 	This script will make a copy of the solid body onto a layer.
!A
!B INSTRUCTIONS:
!B
!B 	PICK BODY TO BE COPIED: Pick the body.
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: layer copy a body")

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

ActivateUndo

Stat= GLPlotOn

Layer_num:!
Layer=InputLayer("LAYER NUMBER ")
IF ExitScript(Destination$) THEN Leave


Pick_body:!
Pkbody= WPKCurrentBody
IF NOT WPKIsEntity(Pkbody) THEN
        Stat=SetInputFormat("n4","")
        E1=WPKPickEntity("PICK BODY TO BE COPIED")
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT WPKIsEntity(E1) THEN Pick_body
        Pkbody= WPKParentBody(E1)
END IF


WPKClearErrorFlag
Layer_rem= CurrentLayer
Stat= SetCurrentLayer(Layer)
E2=WPKCopyBody(Pkbody)
Stat= SetCurrentLayer(Layer_rem)

ActivateUndo
Stat= AdvanceUndoNumber("copy body to layer")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Layer_num

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