
! script name: circles.d/radpointent
! topic: construct circle defined by radius and tangent point

!A
!A NAME:
!A
!A 	Rad: Point: Tangent
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle of a known radius tangent to an
!A 	element and passing though a specified point.
!A 
!A~ image location - images/radpttan.gif
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE RADIUS: Enter radius of circle to be constructed.
!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 TANGENT ELEMENT: Pick element that will be tangent to
!B 		the circle constructed.
!B
!B 	PICK LEFT/RIGHT OF TANGENT ELEMENT: Pick side of
!B 		tangent element that the circle should be constructed on.
!B 		NOTE: This question will only be asked if there is a choice.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: rad: point: tangent ")


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


DEG

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

Circle_loop:!
P1=XyzInput("INPUT",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
T1=0

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

Dist=DistPtEntity(P1,E2)

IF (Dist>0.0001) THEN
	C1=PickRadTwoTan(Radius,E2,T2,P1,T1,WsUNTRIMMED)
ELSE
	Pt=InputFreePoint("PICK LEFT/RIGHT OF TANGENT ELEMENT")
	IF (ExitScript(Destination$)) THEN Leave

	S1=PtLeftRight(E2,Pt)

	C1=Fillet(Radius,P1,1,E2,S1,1,WsUNTRIMMED)

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

GOTO Circle_loop

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