
! script name: parasolids.d/pkzstocksection
! solids: makes a sheet body which is a plane section.

!A
!A NAME:
!A
!A 	Z Stock Section
!A
!A DESCRIPTION:
!A
!A 	This script makes a sheet body which is a z section of
!A 	the picked body. The original body is unmodified.
!A
!B INSTRUCTIONS:
!B
!B 	PICK BODY: Pick the body to be sectioned.
!B
!B 	Z LEVEL: Enter the z level of the section
!B 		in the current workplane.
!B
!B NOTES:
!B
!B 	This script is relative to the current workplane.
!B
!B 	The sheet body created for the section is a new body which will
!B 	have the current layer and color. It is recommended that the user
!B 	change layer and/or color to create the section, otherwise
!B 	the section will be hidden by the solid body.
!B
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: z stock section ")

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


Stat= GLPlotOn
Ploop:!
ActivateUndo

E1=WPKPickEntity("PICK SOLID BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Ploop

Body1= WPKParentBody(E1)
Body_type= WPKBodyType(Body1)
IF Body_type<> WsPKSolidBody THEN Ploop

E2=WPKPickEntity("PICK STOCK BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E2) THEN Ploop

Body2= WPKParentBody(E2)
Body_type= WPKBodyType(Body2)
IF Body_type<> WsPKSolidBody THEN Ploop


Zlevel:!
stat= SetInputFormat("n4","")
Zlevel=GetValue("Z LEVEL",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Zvalue= LastPickZ(Zvalue)

WPKClearErrorFlag
Pkbody= WPKZStockSection(E1,E2,Zlevel)

ActivateUndo
Stat= AdvanceUndoNumber("stock section")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Zlevel

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


