
! script name: 3dextend.d/cconttaperpln
! 3dtopic: extend contour with taper bicubic surface to a plane

!A
!A NAME:
!A
!A 	Contour Taper Projection: Bicubic
!A
!A DESCRIPTION:
!A
!A 	This script will create a new bicubic surface by extending a contour
!A 	the specified taper to a specified plane.
!A
!B INSTRUCTIONS:
!B
!B 	TAPER ANGLE: Enter the angle of taper.
!B
!B 	PICK PLANE: Pick the plane of the bottom.
!B
!B 	PICK PROJECTION LINE: Pick the line defining the direction
!B 		of projection.
!B
!B 	PATCH WIDTH ALONG EDGES: Enter the width of the patch to be used.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: cubic contour taper to plane ")

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

Stat=SetInputFormat("n4","")
Stat=SetAngleEquals(Taper_angle)
Taper_angle=InputAngle("TAPER ANGLE")
IF ExitScript(Destination$) THEN Leave

Pick_plane: Stat=SetInputFormat("n4=","")
Project_plane=PickEntity("PICK PLANE ")
IF ExitScript(Destination$) THEN Leave
Etype=EntityType(Project_plane)
IF Etype<>WsPlaneSolidEnt THEN Pick_plane

Pick_line: Stat=SetInputFormat("n4=","")
Project_line=PickSpecificEnt("PICK PROJECTION LINE ",WsPickLines)
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: StdWorkplane
Stat=SetInputFormat("n0","")
Contour=PickGroupEnt("PICK CONTOUR ",0)
Stat=SetPickMask(WsPickNoSurf)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour) THEN Intersect2
Stat=SetPickMask(WsPickAll)

Dir1=1
Norm_line=SurfNormalLine(Project_plane,0.0,0.0,1.0,WsForward)
Proj_center=ParameterPt(Norm_line,0.0)
Plane_normal=LineVector(Norm_line)
Proj_vector=LineVector(Project_line)

Extension_surf=ExtendContour(WsTaperExt,WsCubicSurfEnt,Contour,Dir1,Taper_angle,U_width,V_width,Tol,Proj_Center,Plane_normal,Proj_Vector)

Stat=DeleteEntity(Proj_vector)
Stat=DeleteEntity(Proj_Center)
Stat=DeleteEntity(Norm_line)
Stat=DeleteEntity(Plane_normal)

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

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