
! script name: v3dinter.d/flowcurve
! var_topic: generates a curve along a surface flow curve

!A
!A NAME:
!A
!A 	Flow Curve	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script generates a curve along a flow curve on a surface.  A flow
!A 	curve is a curve of either constant U or constant V parameter on the
!A 	surface.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE: Pick the surface to be used for generating the flow curve.
!B
!B 	Ucurve or Vcurve:
!B 		U - Select Ucurve to generate a curve of constant U parameters.
!B 		V - Select Vcurve to generate a curve of constant V parameters.
!B
!B 	PARAMETER VALUE (0 - 1): Enter the constant parameter that determines
!B 		the U or V curve.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: flow curve ")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[256]
DIM Surface$[256]
DIM Name$[256]
DIM T_var$[256]

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

ActivateUndo
Tol=NamedVarVal("3D Cutting Tol",Ws3DSystemVars,0.005)

Pick_surface: !
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n0","")
Surface=PickEntity("PICK SURFACE",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Surface) THEN Pick_surface
Stat= EntityNameCheck(Surface,Surface$)

Stat=SetPickMask(WsPickGeometry)
Stat=SetInputFormat("a1=",",U,V,")
Stat=SetEqualsValue(0,"U")
Which_edge=GetValue("  Ucurve or Vcurve ",Answer$)
IF ExitScript(Destination$) THEN Leave
Which_edge=5*(Answer$="U")+6*(Answer$="V")

Stat=SetEqualsValue(0.0)
Stat=SetInputFormat("n4","")
Para_value=GetValue("PARAMETER VALUE (0 - 1) ",Answer$)
IF ExitScript(Destination$) THEN Leave
No_t_var= LastVariableInput(T_var$)


Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CURVE: Flow curve")
Stat= SetRecDelLastExec
Stat= Set3dInterOffset(0.0)
V1= FreeParameter("Which edge",Which_edge)
V2= FreeParameter("Tolerance",Tol)
IF No_t_var THEN
        V4= FreeParameter("Parameter",Para_value)
ELSE
        V4= FreeParameter("Parameter",T_var$)
END IF
C1= EdgeCurve(Surface$,V1,V2,WsForward,V4)
Stat= AutoNameGroup(C1,Name$)
Stat= SetNoPathFlag(C1,WsTrue)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(C1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("flow curve")
	Stat= AddGroupToUndo(WsUBCreateMode,C1,1,WsTrue)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Pick_surface

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