
! script name: circles.d/offsetcircle
! topic: construct concentric circle

!A
!A NAME:
!A
!A 	Offset Circle
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle who's radius differs from the existing
!B 	circle by the parallel distance.
!A
!B INSTRUCTIONS:
!B
!B 	PARALLEL DISTANCE: The absolute difference in the length of
!B 		the radius' of the two circles.
!B
!B 	PICK CIRCLE: Pick the circle referenced for the parallel distance.
!B
!B 	PICK INSIDE/OUTSIDE OF CIRCLE: This indicates the side the
!B 		offset circle will be constructed on.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: offset circle ")

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

DEG

ActivateUndo
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1


Distr=NamedVarVal("parallel distance",WsSystemVars,.25)

Circle_loop:!
Stat=SetEqualsValue(Distr)
Stat=SetInputFormat("n4=","")

Distance=GetValue("PARALLEL DISTANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Distr=Distance

Circle=PickSpecificEnt("PICK CIRCLE",WsPickCircles)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Circle) THEN Circle_loop

stat= SetWorkplane(Circle)

Pt=InputFreePoint("PICK LEFT/RIGHT OF CIRCLE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Circle_loop

Pc= CircleCenter(Circle)
R= CircleRadius(Circle)
R= ABS(R)

R1= DistTwoPts(Pc,Pt)
IF (R1< R ) THEN
	Radius= R-Distance
ELSE
	Radius= R+Distance
END IF

C1= RadiusCenter(Radius,Pc)


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

GOTO Circle_loop

Leave:!
IF Active_workplane THEN
        Stat=SetWorkplane(Work)
ELSE
        StdWorkplane
END IF
Vdist=CreateVariable("parallel distance",WsSystemVars,Distr)

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