
! script name: vcircles.d/concentric
! var_topic: construct circles defined by radius and center

!A
!A NAME:
!A
!A 	Center: Several Radii	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs several circles of a known radii about a point.
!A
!B INSTRUCTIONS:
!B
!B 	CENTER POINT: Pick the center point to be used for the concentric
!B 		circles.
!B
!B 	CIRCLE RADIUS: Enter the radius of the circle.  This question will be
!B 		repeated until another script or exit script is selected.
!B
!# see also - points.d/xyzinput.hlp

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

DIM Answer$[256]
DIM Name$[256]
DIM Center$[256]
DIM Destination$[256]
DIM Radius_var$[256]
DIM Rname$[256]
DEG

Var_object= CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Pick_point:Stat=SetInputFormat("n4=","")
E1=PickEntity("CENTER POINT")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_point
T= LastPickPara
Pick_return= CurrPickReturn
Stat= EntityNameCheck(E1,Center$)
Pc= ParameterReturnPt(E1,T,Pick_return)
Stat=SetEqualsValue(Radius)
Stat=SetLastPoint(Pc)
Stat= DeleteEntity(Pc)

Circle_loop:Pc= ParameterReturnPt(Center$,T,Pick_return)

Circle_radius:Stat=SetInputFormat("n4=","")
Radius=InputRadius("CIRCLE RADIUS")
IF ExitScript(Destination$) THEN Leave
No_radius_var= LastVariableInput(Radius_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
	IF NOT ValidDependency(C1) THEN Circle_radius
	No_radius_var=0
	Stat= EntityNameCheck(C1,Radius_var$)
END IF
Stat= DeleteEntity(Pc)

Stat= GenerateVarName(WsCircleEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CIRCLE: Radius center")
Stat= SetRecDelLastExec
SELECT Pick_return
CASE WsGeometryEnd
	Pc= ParameterReturnPt(Center$,T,WsGeometryEnd)
CASE WsGeometryMid
	Pc= ParameterReturnPt(Center$,T,WsGeometryMid)
CASE WsGeomCenter
	Pc= ParameterReturnPt(Center$,T,WsGeomCenter)
END SELECT
IF No_radius_var THEN
	V1= FreeParameter("Radius",Radius)
	C1=RadiusCenter(V1,Pc)
ELSE
	C1=RadiusCenter(Radius_var$,Pc)
END IF
Stat= NameEntity(C1,Name$)
Stat= DeleteEntity(Pc)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(C1)
Stat= PlotEntity(Center$)

ActivateUndo
Stat= AdvanceUndoNumber("concentric circle")
Stat= AddItemToUndo(WsUBCreateMode,C1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Circle_loop

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

