
! script name: pksurfaces.d/pksolidfromsheet
! solids: make a solid from a sheet body

!A
!A NAME:
!A
!A 	Solid From Sheet
!A
!A DESCRIPTION:
!A
!A	This script will attempt to make a solid from a sheet body by
!A	filling in any holes or gaps. If successful a new body is
!A	created and the sheet body is deleted.
!B
!B INSTRUCTIONS:
!B
!B 	PICK SHEET BODY: Pick the parasolid sheet body.
!B
!B
!B NOTE:
!B
!B	This function cannot always be successful. 
!B	Several methods are tried by this function.
!B
!B	The first method tried is to fill the gaps by capping with
!B	analytic surfaces ( plane, cylinder, cone, sphere, torus )
!B
!B	The function then tries to fill the gap by growing
!B	from the surrounding faces.
!B
!B	If the sheet body needs several holes filled by different means,
!B	it may fail even if one of the above methods would work for
!B	an individual gap.
!B
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: solid from sheet ")

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


ActivateUndo
Stat= GLPlotOn
Ploop:!

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

Body= WPKParentBody(E1)
Body_type= WPKBodyType(Body)
IF Body_type<> WsPKSheetBody THEN Ploop


WPKClearErrorFlag
E2= WPKSolidFromSheet(E1)

ActivateUndo
Stat= AdvanceUndoNumber("solid from sheet")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Ploop

Leave:!
LowerColorBox
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
