
! script name: vlines.d/twopoints
! var_topic: construct line through two picked points

!A
!A NAME:
!A
!A 	Two Picked Points --- VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line through two points. The coordinates
!A 	of the points are input in this script.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING POINT: Pick the starting point for the line.
!B
!B 	ENDING POINT: Pick the ending point for the line.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: two picked points ")

DIM Answer$[256]
DIM Point1$[256]
DIM Point2$[256]
DIM Name$[256]
DIM Destination$[256]
DEG

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


ActivateUndo
stat= SetInputFormat("n4","")
Line_loop:E1=PickEntity("STARTING POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Line_loop
Stat= EntityNameCheck(E1,Point1$)
T1= LastPickPara
Pick_return1= CurrPickReturn
Ps= ParameterReturnPt(E1,T1,Pick_return1)

Pick_line2:Stat=SetLastPoint(Ps)
E2=PickEntity("ENDING POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E2) THEN Pick_line2
Stat= EntityNameCheck(E2,Point2$)
T2= LastPickPara
Pick_return2= CurrPickReturn
Pe= ParameterReturnPt(E2,T2,Pick_return2)
Stat=SetLastPoint(Pe)

Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)


Stat= GenerateVarName(WsLineEnt,Name$)

RecordFunctionOn
Stat= RecordDescr("LINE: Two points")
Stat= SetRecDelLastExec
SELECT Pick_return1
CASE WsGeometryEnd
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryEnd)
CASE WsGeometryMid
        Ps= ParameterReturnPt(Point1$,T1,WsGeometryMid)
CASE WsGeomCenter
        Ps= ParameterReturnPt(Point1$,T1,WsGeomCenter)
END SELECT
SELECT Pick_return2
CASE WsGeometryEnd
        Pe= ParameterReturnPt(Point2$,T2,WsGeometryEnd)
CASE WsGeometryMid
        Pe= ParameterReturnPt(Point2$,T2,WsGeometryMid)
CASE WsGeomCenter
        Pe= ParameterReturnPt(Point2$,T2,WsGeomCenter)
END SELECT
L1=LineTwoPoints(Ps,Pe)
Stat= NameEntity(L1,Name$)
Stat= DeleteEntityList(Ps,Pe)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Point1$)
Stat= PlotEntity(Point2$)
Stat= PlotEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,L1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Line_loop

Leave:!
Stat= DeleteEntityList(Ps,Pe)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

