
! script name: 3druled.d/gconttaperpln
! 3dtopic: extend contour with taper ruled surface to a plane

!A
!A NAME:
!A
!A 	Ruled: Variable Taper Project
!A
!A DESCRIPTION:
!A
!A 	This script will create a new ruled surface by extending a contour the
!A 	specified taper to a specified plane. The tapers are specified at
!A 	various locations along the contour.
!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 of the taper.
!B
!B 	TAPER ANGLE # : Enter the angle of the taper at this location.
!B
!B 	PICK PLANE: Pick the plane of the bottom.
!B
!B 	PICK PROJECTION LINE: Pick the line defining
!B 		the direction of projection.
!B
!B 	PATCH WIDTH ALONG EDGES: Enter the width of the
!B 		patch to be used.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

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

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 Pick_plane
Rcount=Rcount+1

GOTO Pick_fillet_loop

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","")
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR ",0)
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)

Flat_start=1
Flat_end=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_vector)
Stat=DeleteEntity(Proj_Center)
Stat=DeleteEntity(Norm_line)
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
