
! script name: 3druled.d/vconttaper
! 3DTOPIC: extend contour with variable taper ruled surface

!A
!A NAME:
!A
!A 	Ruled Variable Taper Extension To Contour.
!A
!A DESCRIPTION:
!A
!A 	This script will create a new ruled surface by extending 
!A 	a contour with the specified variable tapers.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING TAPER ANGLE: Enter the angle of taper.
!B
!B 	ENDING TAPER ANGLE: Enter the angle of taper.
!B
!B 	Z CONSTANT: Enter the z of the bottom.
!B
!B 	PATCH WIDTH ALONG EDGE: Enter the width of the patch to be used along
!B 		the edge.
!B
!B 	TOLERANCE: Enter the amount of variation allowed.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: ruled contour taper 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)

Start:!
StdWorkplane

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

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

Stat=SetInputFormat("n4=","")
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: StdWorkplane
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

Extension_surf=VarTaperExtCont(WsRuledSurfEnt,Contour,Dir1,Start_taper,End_taper,U_width,V_width,Tol,Proj_Center,Plane_normal,Proj_vector)

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

ActivateUndo
Stat= AdvanceUndoNumber("ruled surf")
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
