
! script name: vpoints.d/endpoint
! var_topic: create point at endpoint of an element

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

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

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
IF T <= 0.3 THEN
	T= 0.0
ELSE
	IF T> 0.3 AND T< 0.6 THEN
		T= 0.5
	ELSE
		T= 1.0
	END IF
END IF
Stat= EntityNameCheck(E1,Name1$)


Stat= GenerateVarName(WsPointEnt,Name$)

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

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

ActivateUndo
Stat= AdvanceUndoNumber("end point")
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


