
! script name: circles.d/dynamic2pts
! topic: construct arc defined by end points and radius

!A
!A NAME:
!A
!A 	Rad: Two Points with Dynamic endpoint.
!A
!A DESCRIPTION:
!A
!A 	This script constructs an arc of known radius with the two end points
!A 	defined.
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE RADIUS: Enter radius of arc to be constructed.
!B
!B 	FIRST POINT ABS X,Y: Enter the X,Y coordinates of the first
!B 		point, which will be one of the end points of the arc
!B 		constructed.  NOTE: See XYZ INPUT OPTIONS.
!B	
!B
!C NOTES:
!C
!C 	The dynamic input mode is an option that may be turned off by
!C 	setting the variable "Grapical 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 rad: two points ")

DIM Destination$[256]
DIM Answer$[256]
REAL Params(0:10)

Graphical_mode=NamedVarVal("Graphical mode",WsSystemVars,1.0)
IF NOT Graphical_mode THEN LOAD "circles.d/rad2points"


ActivateUndo
Start:!
Dynamic_length1= GetDefault(WsDynamicLength1)
Dynamic_radius= GetDefault(WsDynRadiusDefault)

Stat= SetDefaults(WsDynamicLength1,Dynamic_radius)


DEG
stat= SetInputFormat("n4b","")
Radius=InputRadius("CIRCLE RADIUS, (+ cw, -ccw) ",WsRadiusInput,WsSigned)
IF (ExitScript(Destination$)) THEN Leave


Circle_loop:!
stat= SetInputFormat("n4b","")
P1=XyzInput("FIRST POINT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

PlotOff
P2= PtIncrXyz(P1,ABS(Radius),0.0,0.0)
Dir1= (Radius> 0)- (Radius< 0)
C1=RadiusTwoPoints(Radius,P1,P2,Dir1)
Stat= MakeInvisible(Ps)
Stat= MakeInvisible(Pe)
Stat= MakeInvisible(C1)
PlotOn

Vnum= LastPickView
stat= SetInputFormat("n4b","")
Params(0)= Radius
Params(1)= Dir1
Params(2)= WsFalse
Stat=DynamicEntity(Vnum,C1,P1,P2,WsDynTwoPtCircle,"PICK ENDPOINT",Params,Num_params)
IF (ExitScript(Destination$)) THEN 
	Stat=DeleteEntity(C1,WsTrue)
	GOTO Leave
END IF

Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
Stat= MakeVisible(C1)
Stat= PlotEntity(C1)

ActivateUndo
Stat= AdvanceUndoNumber("circle")
Stat= AddItemToUndo(WsUBCreateMode,C1)
GOTO Circle_loop

Leave:!
Stat= SetDefaults(WsDynamicLength1,Dynamic_length1)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 IF Destination$= "SCRIPTSTART" THEN Start
         IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END
