
! script name: draft.d/fillboundary
! topic: fill area inside exterior contour and outside interior islands

!A
!A NAME:
!A
!A 	Area Fill
!A
!A DESCRIPTION:
!A
!A	This script will fill the area inside the exterior contour and outside
!A 	the interior islands.
!A
!B INSTRUCTIONS:
!B
!B 	PICK EXTERIOR CONTOUR: Pick the exterior
!B 		boundary of the fill area.  The contour had to
!B 		be created by types or by auto link.
!B
!B 	NUMBER OF ISLANDS: Enter the number of interior islands.
!B
!B 	PICK ISLAND # : Pick the interior islands.
!B 		The island contour(s) had to be created by
!B 		types or by auto link.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: fill boundary ")

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

Current_pen= CurrentColor
RaiseColorBox

DeActivateUndo
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

Boundary_loop:!
Contour=PickEntity("PICK EXTERIOR CONTOUR",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidGeometry(Contour)) THEN Boundary_loop

Closed=IsContClosed(Contour)
IF NOT Closed THEN Boundary_loop

Stat=SetInputFormat("n0","")
Nisles=GetValue("NUMBER OF ISLANDS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Islands=CreateGroup("ISLANDS")
FOR I=1 TO Nisles

	Isle=PickEntity("PICK ISLAND #"&VAL$(I))
	IF (ExitScript(Destination$)) THEN Leave

	Stat=AddToGroup(Islands,Isle)
NEXT I

Fill_pen= CurrentColor
IF Fill_pen= 0 THEN Fill_pen= 10

Bound1= Boundary(Contour,Islands,"Boundary")

Fill1= FillBoundary(Bound1,Fill_pen)

GraphicsFlush


Stat=DeleteEntity(Islands)
GOTO Boundary_loop

Leave:!

stat= SetCurrentColor(Current_pen)
LowerColorBox
Stat=DeleteEntity(Islands)
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	  LOAD "typecontrol"
ELSE
	  LOAD Destination$
END IF
END
