
! script name: 3dextend.d/ctrimtanext
! 3dtopic: extend trim curve with tangent bicubic surface

!A
!A NAME:
!A
!A 	Tangent Extend Trim Curve: Bicubic
!A
!A DESCRIPTION:
!A
!A 	This script will create a new bicubic surface by extending the trim
!A 	curve of the surface the specified distance.  The new surface, which
!A 	extends the trim curve of the original surface, will be tangent to the
!A 	original surface.
!A
!B INSTRUCTIONS:
!B
!B 	EXTENSION DISTANCE: Enter the amount of extension.
!B
!B 	PATCH WIDTH ALONG EDGES: Enter the width of the patch to be used along
!B 		the edge.
!B
!B 	PICK TRIM CURVE ON SURFACE : Pick the trim curve on surface.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: cubic trim curve tangent extension")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]

IF ARGC<2 THEN
        Ext_type= WsTangent
ELSE
        Ext_type= WsPlaneTangentExt
END IF

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

Start:!
StdWorkplane

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Extend_dist)
Extend_dist=GetValue("EXTENSION DISTANCE",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Extend_dist=0 THEN Start

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=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n0","")
Surface=PickEntity("PICK TRIM CURVE ON SURFACE ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Surface) THEN Intersect2

Which1=LastSurfTrimPick(Surface)

Stat=SetPickMask(WsPickGeometry)

Dist=Extend_dist
Dir1=1

Extension_surf=TrimExtendSurf(Ext_type,WsCubicSurfEnt,Surface,Which1,Dir1,Dist,U_width,V_width,Tol)

ActivateUndo
Stat= AdvanceUndoNumber("cubic surface")
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
