
! script name: circles.d/rad2tangents
! topic: construct circle defined by radius and tangent to two elements

!A
!A NAME:
!A
!A 	Rad: Two Tangents
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle of known radius tangent to two elements.
!A
!A~ image location - images/rad2tan.gif
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE RADIUS: Enter radius of circle to be constructed.
!B
!B 	PICK FIRST TANGENT ELEMENT: Pick one of the two elements
!B 		that will be tangent to the circle constructed.
!B
!B 	PICK SECOND TANGENT ELEMENT: Pick the second element
!B 		that will be tangent to the circle constructed.
!B

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

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


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

ActivateUndo
stat= SetInputFormat("n4","")
Radius=InputRadius("CIRCLE RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Circle_loop:!
E1=PickEntity("PICK FIRST TANGENT ELEMENT")
IF (ExitScript(Destination$)) THEN Leave
T1=LastPickPara

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

C1=PickRadTwoTan(Radius,E1,T1,E2,T2,WsUNTRIMMED)

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

GOTO Circle_loop

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