
! script name: vpoints.d/nearest
! var_topic: create point along an element 

!A
!A NAME:
!A
!A 	point along an element -- VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script creates a point along an element.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY: Pick the element that is to be used to determine
!B 		the point location.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: nearest ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name1$[256]
DIM Name$[256]


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


ActivateUndo
Pick_loop:E1=PickEntity("PICK ENTITY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_loop
T= LastPickPara
Stat= EntityNameCheck(E1,Name1$)


Stat= GenerateVarName(WsPointEnt,Name$)

RecordFunctionOn
Stat= RecordDescr("POINT: Nearest")
Stat= SetRecDelLastExec
V1= FreeParameter("T",T)
Pt= ParameterPt(Name1$,V1)
Stat= NameEntity(Pt,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Name1$)
Stat= PlotEntity(Name$)
Stat=SetLastPoint(Pt,WsXyzInput)

ActivateUndo
Stat= AdvanceUndoNumber("nearest pt")
Stat= AddItemToUndo(WsUBCreateMode,Pt)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_loop

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


