
! script name: 3dextend.d/ccontcirext
! 3dtopic: extend contour with circular arc surface

!A
!A NAME:
!A
!A 	Circle Extend Contour: Bicubic
!A
!A DESCRIPTION:
!A
!A 	This script will create a new bicubic surface by extending a contour
!A 	along a circular arc.
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE RADIUS: Enter the circle radius.
!B
!B 	EXTENSION ANGLE ( less than 180 ): Must be less than 180 deg.
!B
!B 	PATCH WIDTH ALONG EDGES: Enter the width of the patch to be used along
!B 		the edge.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: cubic contour circle extension")

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)
Active_workplane=0
Work=CurrentWorkplane
IF ValidGeometry(Work) THEN Active_workplane=1

Start:!

Stat=SetInputFormat("n4=","")
Radius=InputRadius("CIRCLE RADIUS",WsRadiusInput,WsSigned)
IF ExitScript(Destination$) THEN Leave
IF Radius=0 THEN Start

Angle=InputAngle("EXTENSION ANGLE ( less than 180 )")
IF ExitScript(Destination$) THEN Leave

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

Intersect2:!
Stat=SetInputFormat("n0","")
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR ",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour) THEN Intersect2
Stat=SetPickMask(WsPickAll)

Proj_Vector=PointXYZ(0.0,0.0,1.0)
Proj_Center=PointXYZ(0.0,0.0,1.0)
Plane_normal=PointXYZ(0.0,0.0,1.0)

StdWorkplane

Dir1=WsForward

Extension_surf=ExtendContour(WsCircleExt,WsCubicSurfEnt,Contour,Dir1,Radius,U_width,V_width,Tol,Proj_Center,Proj_Vector,Plane_normal,Angle)

Stat=DeleteEntity(Proj_Vector)
Stat=DeleteEntity(Proj_Center)
Stat=DeleteEntity(Plane_normal)

ActivateUndo
Stat= AdvanceUndoNumber("cubic surface")
Stat= AddItemToUndo(WsUBCreateMode,Extension_surf)

IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF

GOTO Intersect2

Leave:!
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
Stat=SetPickMask(WsPickGeometry)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
