
! script name: solids.d/cylinderrev
! 3dtopic: construct revolution for cylinder

!A
!A NAME:
!A
!A 	Revolution: cylinder with corner radii along Axis
!A
!A DESCRIPTION:
!A
!A 	This script will construct a cylinder using the line that is graphically
!A 	picked as the axis of the cylinder.  The length of the cylinder 
!A	is determined by the length of the axis line picked.  The type of
!A 	cylinder constructed will depend on the pass parameter.
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS: Enter the radius of the cylinder.
!B
!B 	CORNER RADIUS: Enter the corner radius of the cylinder.
!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 	PICK AXIS LINE: Pick the line to be used as the axis of the cylinder.
!B
!C NOTES:
!C
!C 	The U contours of a cylinder constructed as a revolution are the lines
!C 	and the V contours are the circles.
!C
!D 	This script has 3 pass parameters available.  They are:
!D
!D 		0 - ClosedEnds
!D 		1 - OpenFrontEnd
!D 		2 - OpenBackEnd
!D

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

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

C_type=0
IF ARGC>1 THEN
	Type$=ARGV(1)
	C_type=VAL(Type$)
END IF

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        R1= 25
	R3= 3
ELSE
        R1= 1
	R3= 0.125
END IF
Astart= 0
Angle= 180

Cloop:!

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

Stat=SetRadiusEquals(R3)
R3=InputRadius("CORNER RADIUS")
IF ExitScript(Destination$) THEN Leave
R3=ABS(R3)

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=RevolutionCone(Axis_line,C_type,R1,R2,Astart,Angle,R3,Direction)

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

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