
! script name: pksurfaces.d/pkcontourtaper
! solids: extend contour with tapered sheet.

!A
!A NAME:
!A
!A 	Contour Taper Extension Sheet
!A
!A DESCRIPTION:
!A
!A 	This script will create a new sheet body by extending a contour
!A 	with the specified taper.
!A
!B INSTRUCTIONS:
!B
!B 	TAPER ANGLE: Enter the angle of taper.
!B
!B 	Z CONSTANT: Enter the z of the bottom.
!B
!B 	PATCH WIDTH ALONG CONTOTR: Enter the width of the patch to be used along
!B 		the contour.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: contour taper extension sheet")

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)

Stat= GLPlotOn

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

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Patch_width)
Z_const=GetValue("Z CONSTANT ",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Patch_width)
V_width=GetValue("PATCH WIDTH ALONG CONTOUR",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,Z_const)
Plane_normal=PointXYZ(0.0,0.0,1.0)

Dir1=1

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

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

IF ValidGeometry(Extension_surf) THEN
	WPKClearErrorFlag
	S1=WPKMakeBsurf(Extension_surf)
	Stat=DeleteEntity(Extension_surf)
	PlotOn

	PlotAll
	ActivateUndo
	Stat= AdvanceUndoNumber("contour taper extension")
	Stat= AddItemToUndo(WsUBPKSessionMark)
	WPKErrorCheck
END IF
PlotOn
GOTO Intersect2

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