
! script name: solids.d/torus
! 3dtopic: construct torus

!A
!A NAME:
!A
!A 	Torus: Define
!A
!A DESCRIPTION:
!A
!A 	This script will construct a torus.  A torus is a circular tube.
!A
!A~ image location - images/Torus.gif
!A
!B INSTRUCTIONS:
!B
!B 	AXIAL RADIUS: Enter the distance from the center of the torus to the
!B 		center of the tube.
!B
!B~ image location - images/ToriiRadii.gif
!B
!B 	RADIAL RADIUS: Enter the radius of the tube.
!B
!B 	STARTING AXIAL ANGLE: Enter the starting angle of the torus.
!B
!B 	AXIAL ANGULAR EXTENT: Enter the number of degrees and the direction
!B 		( + CCW, - CW ) from the starting axial angle to the ending
!B 		axial angle.  The axial angular extent determines the ending 
!B 		axial angle.
!B
!B 	STARTING RADIAL ANGLE: Enter the starting angle of the tube.
!B
!B 	RADIAL ANGULAR EXTENT: Enter the number of degrees and the direction
!B 		( + CCW, - CW ) from the starting radial angle to the ending
!B 		radial angle.  The radial angular extent determines the ending
!B 		radial angle.
!B
!B 	CENTER POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the center of
!B 		the torus.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ROTATION ANGLE: Enter the orientation angle of the axis of the torus
!B 		in the XY plane.
!B
!B 	X AXIS TILT ANGLE: This represents the angle of tilt of the axis of
!B 		the torus around the X axis.
!B
!B 	Y AXIS TILT ANGLE: This represents the angle of tilt of the axis of
!B 		the torus around the Y axis.
!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
!# see also - points.d/xyzinput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: torus ")

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        R1= 100
        R2= 25
ELSE
        R1= 5
        R2=1
END IF

Cloop:!

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

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

Stat=SetAngleEquals(0)
Axial_astart=InputAngle("STARTING AXIAL ANGLE")
IF ExitScript(Destination$) THEN Leave

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

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

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

Stat=SetInputFormat("n4","")
Pt=XyzInput("CENTER POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(0)
Zangle=InputAngle("ROTATION ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

! Zangle= Zangle- 90

Stat=SetAngleEquals(0)
Xangle=InputAngle("X AXIS TILT ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(0)
Yangle=InputAngle("Y AXIS TILT ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

T1=AngleTransform(Pt,Xangle,Yangle,Zangle,WsWorkplaneVals)

C1=Torus(T1,R1,R2,Axial_astart,axial_angle,radial_astart,radial_angle)
Stat=DeleteEntity(Pt)

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

Leave:!
Stat=DeleteEntity(Pt)

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