
! script name: solids.d/cylinder
! 3dtopic: construct cylinder of specified length, radius, and orientation

!A
!A NAME:
!A
!A 	Cylinder: Define
!A
!A DESCRIPTION:
!A
!A 	This script will construct a cylinder of specified length, radius,
!A 	and orientation at the specified center point.
!A
!A~ image location - images/cylinder.gif
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS: Enter the radius of the cylinder to be constructed.
!B
!B 	LENGTH: Enter the length of the cylinder to be constructed.
!B
!B 	STARTING ANGLE: Enter the starting angle of the cylinder.
!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~ image location - images/AngExtent.gif
!B
!B 	CENTER POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the center
!B 		point of the cylinder.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	AXIS ROTATION ANGLE: Enter the orientation angle of the axis line of
!B 		the cylinder in the XY plane.
!B
!B 	AXIS TILT ANGLE: This represents the angle of tilt of the axis line
!B 		of the cylinder with respect to the XY plane.
!B
!B 	AXIS ROLL ANGLE: This represents the roll angle around the axis line
!B 		of the cylinder.
!B
!C NOTES:
!C
!C 	The U contours of a cylinder are the circles and the V
!C 	contours are the lines.
!C
!# see also - points.d/xyzinput.hlp

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

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25
        Length= 100
ELSE
        Radius= 1
        Length=5
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(Length)
Length=GetValue("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

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

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

Zangle=Zangle-90

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

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

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

C1=Cylinder(T1,Radius,Length,Astart,Angle)
Stat=DeleteEntity(Pt)

ActivateUndo
Stat= AdvanceUndoNumber("cylinder")
Stat= AddItemToUndo(WsUBCreateMode,C1)

GOTO Cloop

Leave:!
Stat=DeleteEntity(Pt)

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