
! script name: v3dextend.d/ctrimvectext
! var_topic: vector extend trim curve with bicubic surface

!A
!A NAME:
!A
!A 	Vector Extend Trim Curve: Bicubic   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will create a new bicubic surface by extending the trim
!A 	curve of the surface with the specified vector displacement.
!A
!B INSTRUCTIONS:
!B
!B 	X SHIFT: Enter the amount of X shift.
!B
!B 	Y SHIFT: Enter the amount of Y shift.
!B
!B 	Z SHIFT: Enter the amount of Z shift.
!B
!B 	PATCH WIDTH ALONG EDGES: Enter the width of the patch to be used along
!B 		the trim curve.
!B
!B 	PICK TRIM CURVE ON SURFACE : Pick the trim curve on surface.
!B

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

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]
DIM Surface$[256]
DIM X_var$[256]
DIM Y_var$[256]
DIM Z_var$[256]
DIM Name$[256]
DIM Patch_var$[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= SetEqualsValue(Xshift)
Xshift= GetValue("X SHIFT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_x_var= LastVariableInput(x_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Yshift)
Yshift= GetValue("Y SHIFT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_y_var= LastVariableInput(y_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Zshift)
Zshift= GetValue("Z SHIFT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_z_var= LastVariableInput(z_var$)

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

Intersect2:!
Pick_loop:!
Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n4","")
Surface=PickEntity("PICK TRIM CURVE ON SURFACE ")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Surface) THEN Pick_loop
Stat= EntityNameCheck(Surface,Surface$)

Which1=LastSurfTrimPick(Surface)

Stat=SetPickMask(WsPickGeometry)

Dist=Extend_dist
Dir1=1


Stat= GenerateVarName(WsCubicSurfEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("BICUBIC: Vector trim extension")
Stat= SetRecDelLastExec
V1= FreeParameter("Which curve",Which1)
V2= FreeParameter("Direction",Dir1)
V3= FreeParameter("Tolerance",Tol)
IF No_x_var THEN
        V4= FreeParameter("Xshift",Xshift)
ELSE
        V4= FreeParameter("Xshift",X_var$)
END IF
IF No_y_var THEN
        V5= FreeParameter("Yshift",Yshift)
ELSE
        V5= FreeParameter("Yshift",Y_var$)
END IF
IF No_z_var THEN
        V6= FreeParameter("Zshift",Zshift)
ELSE
        V6= FreeParameter("Zshift",Z_var$)
END IF
IF No_patch_var THEN
        V7= FreeParameter("Patch width",Patch_width)
ELSE
        V7= FreeParameter("Patch width",Patch_var$)
END IF
Shift_vector= PointXYZ(V4,V5,V6)
S1=TrimExtendSurf(WsVector,WsCubicSurfEnt,Surface$,V1,V2,Shift_vector,V7,V7,V3)
Stat= NameEntity(S1,Name$)
Stat= DeleteEntity(Shift_vector)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(S1) THEN
	Curr_record=0
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("cubic ext surf")
	Stat= AddItemToUndo(WsUBCreateMode,S1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Intersect2

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