
! script name: pksolids.d/pkboundedblock
! solids: construct block from a exterior contour and interior contour holes.

!A
!A NAME:
!A
!A	Bounded Block
!A
!A DESCRIPTION:
!A
!A	This script makes a solid block from an exterior synergy contour.
!A	The interior contours become holes in the solid.
!A
!A~ image location - images/pkboundedblock.gif
!A
!B INSTRUCTIONS:
!B
!B	PICK EXTERIOR CONTOUR: Pick the contour to be used.
!B
!B	# OF INTERIOR CONTOURS: Enter the number of interior contours.
!B
!B	PICK INTERIOR CONTOUR #: Pick the interior contours.
!B
!B	HEIGHT ABOVE CONTOUR: Enter the height of the block above the contour.
!B 		Do not enter a negative number.
!B
!B	DEPTH BELOW CONTOUR: Enter the depth of the block below the contour.
!B 		A positive answer will go down.
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: Bounded Block")

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)


Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Height1)
Height1=InputDepth("HEIGHT ABOVE CONTOUR")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Depth1)
Depth1=InputDepth("DEPTH BELOW CONTOUR")
IF ExitScript(Destination$) THEN Leave

WPKClearErrorFlag
Pkbody=WPKContourBlock(Contour,Islands,Height1,Depth1)
Stat= DeleteEntity(Islands)

ActivateUndo
Stat= AdvanceUndoNumber("bounded block")
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
