
! script name: vruled.d/rconttaper
! var_topic: extend contour with taper ruled surface

!A
!A NAME:
!A
!A 	Ruled: Contour Taper	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will create a new ruled surface by extending a contour with
!A 	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 CONTOUR: 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: ruled contour taper extension")

DIM Destination$[256]
DIM Answer$[256]
DIM Contour$[256]
DIM Patch_var$[256]
DIM Angle_var$[256]
DIM Z_var$[256]
DIM Name$[256]

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

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

Start:!

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

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

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Patch_width)
Patch_width= GetValue("PATCH WIDTH ALONG CONTOUR",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_patch_var= LastVariableInput(Patch_var$)

Intersect2:!
Pick_contour: !
stat= SetInputFormat("a1",",P,")
Stat= SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR #1",0)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Contour) THEN Pick_contour
Stat= EntityNameCheck(Contour,Contour$)

Dir1=1

Stat= GenerateVarName(WsRuledSurfEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("RULED SURFACE: Contour Taper")
Stat= SetRecDelLastExec
IF No_taper_var THEN
        V1= FreeParameter("Taper angle",Taper_angle)
ELSE
        V1= FreeParameter("Taper angle",Taper_var$)
END IF
IF No_z_var THEN
        V2= FreeParameter("Z constant",Z_const)
ELSE
        V2= FreeParameter("Z constant",Z_var$)
END IF
IF No_patch_var THEN
        V3= FreeParameter("Patch width",Patch_width)
ELSE
        V3= FreeParameter("Patch width",Patch_var$)
END IF
V4= FreeParameter("Tolerance",Tol)
Proj_Vector=PointXYZ(0.0,0.0,1.0)
Proj_Center=PointXYZ(0.0,0.0,V2)
Plane_normal=PointXYZ(0.0,0.0,1.0)
Surf1=ExtendContour(WsTaperExt,WsRuledSurfEnt,Contour$,Dir1,V1,V3,V3,V4,Proj_Center,Proj_Vector,Plane_normal)
Stat= NameEntity(Surf1,Name$)
Stat=DeleteEntityList(Proj_Vector,Proj_center,Plane_normal)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(Surf1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("ruled surface")
	Stat= AddItemToUndo(WsUBCreateMode,Surf1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Intersect2

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