
! script name: solids.d/nurbtorus
! 3dtopic: construct torus as a nurb along an axis line

!A
!A NAME:
!A
!A 	Torus: Define as a nurb along an axis line.
!A
!A DESCRIPTION:
!A
!A 	This script will construct a torus.  A torus is a circular tube.
!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 	RADIAL RADIUS: Enter the radius of the tube.
!B
!B 	PICK AXIS LINE: Pick the line to be used as the axis of the torus.
!B
!C NOTES:
!C
!C 	The U contours of a nurb torus are the radial circles and the V contours
!C 	are the axial circles.
!C

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

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

ActivateUndo
Cloop:!

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

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(1.00)
R2=InputRadius("RADIAL RADIUS")
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=NurbTorus(Axis_line,R1,R2,1,Direction)

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

Leave:!
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
