
! script name: offsets.d/fillcutter
! topic: fill area of tool along cutter path

!A
!A NAME:
!A
!A 	Fill Cutter
!A
!A DESCRIPTION:
!A
!A 	This script fills in the area of a
!A 	tool along a defined cutter path.
!A
!B INSTRUCTIONS:
!B
!B 	PICK PATH: Pick the path that will have
!B 		the area of the tool filled in.
!B

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

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

stat= SetInputFormat("n4","")
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

Current_pen=CurrentColor

StdWorkplane

Pick_loop: !
ActivateUndo
Stat=SetPickMask(WsPickNoSurf)
Stat=SetInputFormat("n4","")
Path=PickGroupEnt("PICK PATH",0)
IF (ExitScript(Destination$)) THEN Leave

IF NOT ValidGeometry(Path) THEN Pick_loop

Path_group=ParentGroup(Path,WsPathGroup)
IF NOT ValidGeometry(Path_group) THEN 
! Stat=Highlight(Path,WsPickPen,WsDirArrowOff)
	Tool= GetAssocTool(Path)
	IF NOT ValidGeometry(Tool) THEN 
		Offset_bdy= GetAssocEnt(Path,WsOffsetBdy)
		IF NOT ValidGeometry(Offset_bdy) THEN  Pick_loop
		Cutter_dia=GetUserValue(Offset_bdy,"CUTTER DIA:")
	ELSE
		Cutter_dia=GetUserValue(Tool,"Diameter:")
	END IF
	Path_group= Path
	GOTO Fill_cutter
END IF

! Stat=Highlight(Path_group,WsPickPen,WsDirArrowOff)

Tool= GetAssocTool(Path)
IF ValidGeometry(Tool) THEN 
	Cutter_dia=GetUserValue(Tool,"Diameter:")
ELSE
	Pocket_bdy= GetAssocEnt(Path_group,WsPocketBdy)
	IF NOT ValidGeometry(Pocket_bdy) THEN 
		Offset_bdy= GetAssocEnt(Path_group,WsOffsetBdy)
		IF NOT ValidGeometry(Offset_bdy) THEN Pick_loop
		Cutter_dia=GetUserValue(Offset_bdy,"CUTTER DIA:")
	ELSE
		Cutter_dia=GetUserValue(Pocket_bdy,"CUTTER DIA:")
	END IF
END IF

Fill_cutter:Radius= Cutter_dia*0.5

Element1= GroupElement(Path,1)
Fill_pen= GetColor(Element1)
stat= SetCurrentColor(Fill_pen)

Pr=PointXYZ(0,0,0)
T1=AngleTransform(Pr,0,0,0)
Stat=DeleteEntity(Pr)
D1= Radius/(5*(1+24.4*(CurrentUnits=WsMetric)))
Stat= AnimateSpeed(D1)
stat= AnimateCircle(Radius,Path_group,T1,TpFillTool,fill_pen)

Stat= AnimateData(TpToolSymbol,TpAnimateTool,.5)

Stat=DeleteEntity(T1,WsFalse)
GOTO Pick_loop

Leave:!
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
Stat=SetPickMask(WsPickGeometry)
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pr)
Stat=DeleteEntity(T1)
Stat=SetCurrentColor(Current_pen)

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


