
! script name: pksolids.d/pkplaneboundary
! solids: construct a sheet body from a contour with interiors

!A
!A NAME:
!A
!A 	Bounded Sheet
!A
!A DESCRIPTION:
!A
!A	This script makes a sheet body which corresponds to the interior of
!A	a closed contour with interior holes.
!A
!A~ image location - images/pkboundedsheet.gif
!A
!B INSTRUCTIONS:
!B
!B	PICK EXTERIOR CONTOUR: Pick the esterior contour to be used. 
!B 		This contour is unchanged by this operation.
!B
!B	# OF INTERIOR CONTOURS: Enter the number of interior contours.
!B
!B	PICK INTERIOR CONTOUR #: Pick the interior contours.
!B
!C NOTES:
!C	
!C	The contour must not be self crossing. An open contour will
!C	automatically be closed by joining the end points.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: bounded plane")

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

ActivateUndo

Stat= GLPlotOn
Contour_loop:!
ActivateUndo
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK EXTERIOR CONTOUR")
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidGeometry(Contour)) THEN Contour_loop
Stat=SetPickMask(WsPickGeometry)

Stat= SetSelectedFlag(Contour,WsTrue)
Stat= PlotEntity(Contour)

Stat=SetInputFormat("n0=","")
Stat= SetEqualsValue(0)
Nisles=GetValue("# OF INTERIOR CONTOURS  1 2 3 4 5 ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Islands=CreateGroup("ISLANDS")
FOR I=1 TO Nisles
Pick_isle:Stat=SetPickMask(WsPickNoSurf)
        Isle=PickGroupEnt("PICK INTERIOR CONTOUR #"&VAL$(I))
        IF (ExitScript(Destination$)) THEN Leave
        Stat=AddToGroup(Islands,Isle)
        Stat= SetSelectedFlag(Isle,WsTrue)
        Stat= PlotEntity(Isle)
        Stat=SetPickMask(WsPickGeometry)
NEXT I

Stat= SetSelectedFlag(Contour,WsFalse)
Stat= SetSelectedFlag(Islands,WsFalse)


WPKClearErrorFlag
Pkbody=WPKContPlaneBody(Contour,Islands)
Stat= DeleteEntity(Islands)

ActivateUndo
Stat= AdvanceUndoNumber("bounded plane")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Contour_loop

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