
! 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


Distance=NamedVarVal("parallel distance",WsSystemVars,.25)
Ask_dist=NamedVarVal("ask parallel dist",WsSystemVars,0.0)

Ask_distance:!
IF Ask_dist THEN
   Stat=SetEqualsValue(Distance)
   Stat=SetInputFormat("n4=","")
   Distance=GetValue("PARALLEL DISTANCE",Answer$)
   IF (ExitScript(Destination$)) THEN Leave
END IF


Circle_loop:!
Stat=DynLabel("Distance:"&VAL$(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)

Distance= DynBufferValue(0,Distance)
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:!
Stat= DynLabel("")
IF Active_workplane THEN
        Stat=SetWorkplane(Work)
ELSE
        StdWorkplane
END IF
Vdist=CreateVariable("parallel distance",WsSystemVars,Distance)

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