
! script name: vpoints.d/contourendpts
! var_topic: contour end points.

!A
!A NAME:
!A
!A 	Contour End Points. VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script creates the two endpoints on a contour.
!A
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick an element on the contour.
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: contour end points ")

DIM Destination$[256]
DIM Answer$[256]
DIM Contour$[256]
DIM Name1$[256]
DIM Name2$[256]

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

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

Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)


Stat= GenerateVarName(WsPointEnt,Name1$)
Stat= GenerateVarName(WsPointEnt,Name2$)
RecordFunctionOn
Stat= RecordDescr("POINT: contour end points")
Stat= SetRecDelLastExec
Ps=ContStartPt(Contour$)
Pe=ContEndPt(Contour$)
Stat= NameEntity(Ps,Name1$)
Stat= NameEntity(Pe,Name2$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Contour$)
Stat= PlotEntity(Name1$)
Stat= PlotEntity(Name2$)
IF NOT ValidGeometry(Ps) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("contour end pts")
	Stat= AddItemToUndo(WsUBCreateMode,Ps)
	Stat= AddItemToUndo(WsUBCreateMode,Pe)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

GOTO Pick_contour

Leave:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

