
! script name: 3dfillet.d/fsurftopart
! 3dtopic: generate fillet surface between a surface and a part

!A
!A NAME:
!A
!A 	Fillet: Surf To Part (Fast)
!A
!A DESCRIPTION:
!A
!A 	This script will generate a fillet surface between a surface and
!A 	a part.
!A
!B INSTRUCTIONS:
!B
!B 	FILLET RADIUS: Enter the radius of the fillet to be constructed.
!B
!B 	PATCH WIDTH: Enter the width of the patch to be used.
!B
!B 	PICK SURFACE: Pick  the surface 
!B
!B 	PICK SURFACE GROUP: Pick the  surface group to be used for
!B 		the fillet.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: fillet surface to part ")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]

ActivateUndo
Patch_width=NamedVarVal("3D Default Patch",Ws3DSystemVars,0.25)
Tol=NamedVarVal("3D Fillet Tol",Ws3DSystemVars,0.005)

Start:!
StdWorkplane

Ask_fillet: Stat=SetInputFormat("n4=","")
Radius=InputRadius("FILLET RADIUS")
IF ExitScript(Destination$) THEN Leave
IF Radius<=0 THEN Ask_fillet

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Patch_width)
Patch_width=GetValue("PATCH WIDTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Intersect2: StdWorkplane
Pick_part1:!
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4","")
Surface=PickEntity("PICK SURFACE ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Surface) THEN Pick_part1


Pick_part2:!
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4","")
Part_group=PickGroupEnt("PICK SURFACE GROUP  ",WsSurfaceGroup)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Part_group) THEN Pick_part2

Stat=Highlight(Part_group,WsPickPen,WsDirArrowOff)

Stat=SetPickMask(WsPickGeometry)

Temp_group= CreateGroup("TEMP")
Stat= AddToGroup(Temp_group,Surface)
s1=1
s2=1
Fillet_group=FastFilletParts(Radius,Part_group,S1,Temp_group,S2,Patch_width,Tol)

Stat=DeleteEntity(Temp_group)

ActivateUndo
Stat= AdvanceUndoNumber("fillet surface")
Stat= AddGroupToUndo(WsUBCreateMode,Fillet_group,0,WsFalse)
Stat=DeleteEntity(fillet_group)
GOTO Intersect2

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