
! script name: circles.d/centertangent
! topic: construct circle defined by center and tangent element

!A
!A NAME:
!A
!A 	Center: Tangent
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle of unknown radius about a point
!A 	tangent to an element.
!A
!A~ image location - images/centertan.gif
!A
!B INSTRUCTIONS:
!B
!B 	INPUT CENTER ABS X,Y: Enter the X,Y coordinates of the center
!B 		point of the circle.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	PICK TANGENT ELEMENT: Pick the entity that will be tangent
!B 		to the circle constructed.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: center: tangent ")

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


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

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


E1=PickEntity("PICK TANGENT ELEMENT")
IF (ExitScript(Destination$)) THEN Leave
Pickpt=LastPickPoint

C1=CenterTangent(Pt,E1,Pickpt)

Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pickpt)

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

GOTO Circle_loop

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