
! script name: vpoints.d/contourlenpt
! var_topic: generate a point along a contour at a specified length.

!A
!A NAME:
!A
!A 	Contour Length Point VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will generate a point along a contour at a specified
!A 	arclength.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick the contour.
!B
!B 	LENGTH ALONG CONTOUR: Input the length along the contour
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: contour length point ")

DIM Destination$[256]
DIM Answer$[256]
DIM Contour$[256]
DIM Name$[256]
DIM Num_var$[256]
DIM Dist_var$[256]

Var_object= CheckVarObject
IF ExitScript(Destination$) THEN Leave


ActivateUndo
Pick_loop:!
Contour=PickGroupEnt("PICK CONTOUR")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour) THEN Pick_loop
IF NOT ValidDependency(Contour) THEN Pick_loop
Stat= EntityNameCheck(Contour,Contour$)

Stat=Highlight(Contour,WsPickPen,WsDirArrowsOff)


stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Dist)
Dist= GetValue("LENGTH ALONG CONTOUR ",Answer$)
IF ExitScript(Destination$) THEN Leave
No_dist_var= LastVariableInput(Dist_var$)

Stat= GenerateVarName(WsPointEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("POINT: Point along contour")
Stat= SetRecDelLastExec
IF No_dist_var THEN
         V1= FreeParameter("Distance",Dist)
         P1=ContLengthPoint(Contour$,V1)
ELSE
         P1=ContLengthPoint(Contour$,Dist_var$)
END IF
Stat= NameEntity(P1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Contour$)
Stat= PlotEntity(Name$)
IF NOT ValidGeometry(P1) THEN
      DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("point")
	Stat= AddItemToUndo(WsUBCreateMode,P1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Pick_loop

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