
! script name: solids.d/sphereaxis
! 3dtopic: construct sphere along an axis line

!A
!A NAME:
!A
!A 	Sphere: Sphere along an axis line.
!A
!A DESCRIPTION:
!A
!A 	This script constructs a sphere along an axis line.  A sphere
!A 	is the set of all points in 3d space equidistant from a fixed point.
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS: Enter the radius, the measure of the constant distance from
!B 		the center of the sphere.
!B
!B 	STARTING LENGTH: Enter the controlling extent of the sphere along the
!B 		axis, negative measures backward from the starting point, zero
!B 		is the center or starting point.
!B
!B 	ENDING LENGTH: Enter the controlling extent of the sphere along the
!B 		axis, positive measures forward from the starting point, zero
!B 		is the center or starting point.
!B
!B 		NOTE: The starting length and ending length should not exceed
!B 		the radius of the sphere.  The default value indicates the
!B 		limits.
!B
!B 	STARTING ANGLE: Enter the starting angle of the sphere.  The starting
!B 		angle along with the angular extent are the controlling factor
!B 		for the sphere around the axis.
!B
!B 	ANGULAR EXTENT: Enter the number of degrees and the direction
!B 		( + CCW, - CW ) from the starting angle to the ending angle.
!B 		The angular extent determines the ending angle.
!B
!B 		in the XY plane.
!B
!B      PICK AXIS LINE: Pick the line to be used as the axis of the sphere.
!B
!B
!C NOTES:
!C
!C 	The U contours of a sphere are the circles from the starting length
!C 	to the ending length.  The V contours of a sphere are the circles
!C 	formed from the starting angle to the ending angle.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: axis line sphere ")

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25
ELSE
        Radius= 1
END IF
Astart= 0
Angle= 180

Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(Radius)
Radius=InputRadius("RADIUS")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(-Radius)
Start_length=GetValue("STARTING LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Radius)
End_length=GetValue("ENDING LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Astart)
Astart=InputAngle("STARTING ANGLE")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Angle)
Angle=GetValue("ANGULAR EXTENT",Answer$)
IF ExitScript(Destination$) THEN Leave

Pick_axis:!
Stat=SetInputFormat("n4","")
Axis_line=PickSpecificEnt("PICK AXIS LINE",WsPickLines)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Axis_line) THEN Pick_axis

T=LastPickPara
IF T<=0.5 THEN
	Direction=WsForward
ELSE
	Direction=WsReverse
END IF

C1=AxisLineSphere(Axis_line,Radius,Start_length,End_length,Astart,Angle,Direction)

ActivateUndo
Stat= AdvanceUndoNumber("sphere")
Stat= AddItemToUndo(WsUBCreateMode,C1)
GOTO Cloop

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