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

!A
!A NAME:
!A
!A 	Ruled: Variable Taper
!A
!A DESCRIPTION:
!A
!A 	This script will create a new ruled surface by extending a contour with
!A 	the specified variable tapers. The tapers can be specified at various
!A 	points along the contour.  Between these points, the taper is blended
!A 	between the specified values.
!A
!B INSTRUCTIONS:
!B
!B 	HOW MANY TAPERS ARE TO BE SPECIFIED: Enter the
!B 		number of tapers specified.
!B
!B 	LOCATION OF TAPER # : Specify location on contour
!B 		of the taper.
!B
!B 	TAPER ANGLE # :  Give the taper at this location.
!B
!B 	Z CONSTANT: Enter the z of the bottom.
!B
!B 	ENDPOINT CONDITIONS: Blend, Sharp:  
!B
!B 		B - Blend: The taper is blended in such a way as to become
!B 		    tangent with the ending taper angle.
!B 		S - Sharp: No blending is attempted at the endpoints.
!B
!B 	PATCH WIDTH ALONG EDGE: Enter the width of the
!B 		patch to be used along the edge.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: variable taper ")

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("n0=","")
Stat=SetEqualsValue(3)
Num_tapers=GetValue("HOW MANY TAPERS ARE TO BE SPECIFIED ",Answer$)
IF ExitScript(Destination$) THEN Leave

Cgroup=CreateGroup("TAPERS")
Rcount=1

Pick_fillet_loop:!

Stat=SetInputFormat("n4=","")
Pc=XyzInput("LOCATION OF TAPER #"&VAL$(Rcount)&"  ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

Ask_fillet: Stat=SetInputFormat("n4=","")
Taper1=GetValue("TAPER ANGLE #"&VAL$(Rcount))
IF ExitScript(Destination$) THEN Leave

C1=RadiusCenter(Taper1,Pc)
Stat=HideEntity(C1)
Stat=AddToGroup(Cgroup,C1)
Stat=DeleteEntity(Pc)

IF Rcount=Num_tapers THEN Z_constant
Rcount=Rcount+1

GOTO Pick_fillet_loop

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

Flat_start: Stat=SetInputFormat("a1=",",B,S,")
Stat=SetEqualsValue(0,"B")
Stat=GetValue("ENDPOINT CONDITIONS: Blend, Sharp  ",Answer$)
IF ExitScript(Destination$) THEN Leave
Flat_start=(Answer$="B")
Flat_end=(Answer$="B")

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=GenTaperExtCont(WsRuledSurfEnt,Contour,Dir1,Cgroup,Flat_start,Flat_end,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 Start

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