
! script name: circles.d/threetangents
! topic: construct circle tangent to three elements

!A
!A NAME:
!A
!A 	Three Tangents
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle of unknown radius tangent to three
!B 	elements.  The tangent element to be picked must be a circle, line,
!A 	or point.
!A
!A~ image location - images/3tangents.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK FIRST TANGENT ELEMENT: Pick one of the three elements
!B 		that will be tangent to the circle constructed.
!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

stat=ChangeLabelStr("ScriptNameStatus","Function: three tangents ")

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

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

ActivateUndo
stat= SetInputFormat("n4","")
Ploop:!
E1=PickEntity("PICK FIRST TANGENT ELEMENT")
IF (ExitScript(Destination$)) THEN Leave
T1=LastPickPara

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(E1,T1,E2,T2,E3,T3,0)

Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
Stat=DeleteEntity(P3)
ActivateUndo
Stat= AdvanceUndoNumber("circle")
Stat= AddItemToUndo(WsUBCreateMode,C1)
GOTO Ploop

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