
! script name: lines.d/dynamictwopts
! topic: construct line through two points

!A
!A NAME:
!A
!A 	Dynamic Line: Two XY(Z) Points
!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 ABS X,Y,Z: Enter the X,Y,Z coordinates of the start
!B 		point of the line. You may also pick an existing point
!B		location or entity endpoint.  
!B		NOTE: See XYZ INPUT OPTIONS.
!B		
!B
!B 	PICK LINE END POINT: Pick the end point of the line.
!B 		NOTE: To enter the xyz coordinates change the Input Method
!B		Combo Box to Rectangular, or type R.
!B 		See DYNAMIC INPUT OPTIONS.
!B
!C NOTES:
!C
!C 	The dynamic input mode is an option that may be turned off by
!C 	setting the variable "Graphical mode=0".  To set the variable,
!C 	under "Settings", select "Variables".  The selection box will appear
!C 	at this time.  Select "Graphical mode=1" and change the
!C 	setting to "0".  The dynamic input mode is the default whenever
!C 	Synergy is started.  This change is for this session of Synergy
!C 	only.
!C
!C 	The dynamic input mode may be turned off for future sessions of
!C 	Synergy by going to "Settings" and selecting "Constants".  The editor
!C 	will bring up the setconstants script.  The following line needs
!C 	to be modified (the 1.0 needs to be changed to 0.0):
!C
!C 		V10=CreateVariable("Graphical mode",WsSystemVars,1.0)
!C
!C 	to:
!C
!C 		V10=CreateVariable("Graphical mode",WsSystemVars,0.0)
!C
!C 	The line is near the middle of the script.
!C
!# see also - points.d/dyninput.hlp

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

DIM Answer$[256]
DIM Destination$[256]
DEG

Graphical_mode=NamedVarVal("Graphical mode",WsSystemVars,1.0)

ActivateUndo
Start:!
Units= CurrentUnits
IF Units= WsMetric THEN
        Length1= 25
ELSE
        Length1= 1
END IF

stat= SetInputFormat("n4b","")
Line_loop:Ps=XyzInput("STARTING",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ps) THEN Line_loop

Stat=SetLastPoint(Ps)

IF NOT Graphical_mode THEN 

stat= SetInputFormat("n4b","")
Pe=XyzInput("ENDING",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pe) THEN Line_loop

Stat=SetLastPoint(Ps)
L1= LineTwoPoints(Ps,Pe)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,L1)

ELSE

PlotOff
Pe= PtIncrXyz(Ps,Length1,0.0,0.0)
L1= LineTwoPoints(Ps,Pe)
Stat= MakeInvisible(L1)
Stat= MakeInvisible(Pe)
PlotOn

	Vnum= LastPickView
stat= SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,L1,Ps,Pe,WsDynamicEnd,"PICK LINE END POINT")
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(L1,WsTrue)
        GOTO Leave
END IF
Stat=DeleteEntity(Ps)
PlotOff
Stat=DeleteEntity(Pe)
Pe= ParameterPt(L1,1.0)
Stat=SetLastPoint(Pe)
Stat=DeleteEntity(Pe)
PlotOn
Stat= MakeVisible(L1)
Stat= PlotEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,L1)
END IF

GOTO Line_loop

Leave:!
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 IF Destination$= "SCRIPTSTART" THEN Start
         IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END
