
! script name: solids.d/cirtorus
! 3dtopic: construct torus defined by a circle

!A
!A NAME:
!A
!A 	Torus: Circle
!A
!A DESCRIPTION:
!A
!A 	This script will construct a torus, using the picked circle to
!A 	determine the axial radius, the starting axial angle, the axial
!A 	angular extent, and the orientation of the torus.
!A
!A~ image location - images/cirtorus.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK CIRCLE: Pick the circle to be used as the
!B 		axial diameter of the torus.
!B
!B 	RADIAL RADIUS: Enter the radius of the tube.
!B
!B 	STARTING RADIAL ANGLE: Enter the starting angle of
!B 		the tube. Zero is to the outside of the circle.
!B
!B 	RADIAL ANGULAR EXTENT:Enter the number of degrees and
!B 		the direction ( + CCW, - CW ) from the starting
!B 		radial angle to the ending radial angle.  The
!B 		radial angular extent determines the ending
!B 		radial angle.
!B
!C NOTES:
!C
!C 	The U contours of a torus are the axial circles and the V contours
!C 	are the radial circles.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: torus defined by a circle ")

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


ActivateUndo
Radial_radius=1.0
Radial_as=0.0
Radial_angle=180.0

Cloop:!
Stat=SetInputFormat("n4","")

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

Stat=SetRadiusEquals(Radial_radius)
Radial_radius=InputRadius("RADIAL RADIUS")
IF ExitScript(Destination$) THEN Leave
Radial_radius=ABS(Radial_radius)

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

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

C1=CircleTorus(Pcircle,Radial_radius,Radial_as,Radial_angle)

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

Leave:!

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
