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

!A
!A NAME:
!A
!A 	Tapered  Circle
!A
!A DESCRIPTION:
!A
!A 	This script constructs a circle who's radius differs from the existing
!B 	circle by the specified taper over the z height.
!A
!B INSTRUCTIONS:
!B
!B	HEIGHT: Specify the height. + up/ -down.
!B
!B 	TAPER ANGLE: Specify the taper angle.
!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: tapered circle ")

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

DEG

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


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

Z_height=GetValue("HEIGHT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Taper_angle: Taper_angle=InputAngle("TAPER ANGLE")
IF (ExitScript(Destination$)) THEN Leave

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= ABS(Z_height*TAN(Taper_angle))

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

C1= RadiusCenter(Radius,Pc)

Pz=PointXYZ(0.0,0.0,Z_height)
T1=AngleTransform(Pz,0,0,0,WsWorkplaneVals)
C2=TransformEntity(C1,T1)

Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Pz)
Stat=DeleteEntity(C1)

Stat= PlotEntity(C2)

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

GOTO Taper_angle

Leave:!
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Pz)
Stat=DeleteEntity(C1)
IF Active_workplane THEN
        Stat=SetWorkplane(Work)
ELSE
        StdWorkplane
END IF
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
