
! script name: circles.d/pttwotangents
! topic: construct circle through point and tangent to two elements

!A
!A NAME:
!A
!A 	Point: Two Tangents
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle of unknown radius through a point
!A 	and tangent to two elements.  The tangent element to be picked must
!A 	be a circle, line, or point.
!A
!A~ image location - images/pt2tangents.jpg
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y: Enter the X,Y coordinates of the point, through
!B 		which the circle constructed will pass.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	PICK SECOND TANGENT ELEMENT: Pick the second of the three
!B 		elements that will be tangent to the circle constructed.
!B
!B 	PICK THIRD TANGENT ELEMENT: Pick the third element that
!B 		will be tangent to the circle constructed.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: point: two tangents ")

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

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

ActivateUndo
stat= SetInputFormat("n4","")
Ploop:!
Pt=XyzInput("INPUT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
T1=0

E2=PickEntity("PICK SECOND TANGENT ELEMENT")
IF (ExitScript(Destination$)) THEN Leave
T2=LastPickPara

E3=PickEntity("PICK THIRD TANGENT ELEMENT")
IF (ExitScript(Destination$)) THEN Leave
T3=LastPickPara

C1=ThreeTangents(Pt,T1,E2,T2,E3,T3,0)

Stat=DeleteEntity(Pt)
ActivateUndo
Stat= AdvanceUndoNumber("circle")
Stat= AddItemToUndo(WsUBCreateMode,C1)

GOTO Ploop

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