
! script name: solids.d/coneangle
! 3dtopic: construct cone defined by an angle

!A
!A NAME:
!A
!A 	Cone: Angle
!A
!A DESCRIPTION:
!A
!A 	This script will construct a cone using the line that is graphically
!A 	picked as the axis of the cone, with specified starting radius and
!A 	cone angle (taper).  The length of the cone is determined by the length
!A 	of the axis line picked; the ending radius is determined by the cone
!A 	angle, the starting radius, and the length of the cone.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING RADIUS: Enter the starting radius of the cone.
!B
!B 	CONE ANGLE: Enter the angle of taper of the cone.
!B
!B 	STARTING ANGLE: Enter the starting angle of the cone.
!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 cone.
!B
!C NOTES:
!C
!C 	The U contours of a cone are the circles and the V contours are the
!C 	lines.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: cone defined by an angle ")

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        R1= 25
        Length= 100
ELSE
        R1= 1
        Length=5
END IF
Astart= 0
Angle= 180
Cone_angle=30.0
Cloop:!

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

Ask_angle:Stat=SetAngleEquals(Cone_angle)
Cone_angle=InputAngle("CONE ANGLE")
IF ExitScript(Destination$) THEN Leave
IF (Cone_angle> 179.99) OR (Cone_angle< -179.99) THEN Ask_angle

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

Axis_line:Axis_line=PickSpecificEnt("PICK AXIS LINE",WsPickLines)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Axis_line) THEN Axis_line
T=LastPickPara
IF T<=0.5 THEN
        Direction= WsForward
ELSE
        Direction= WsReverse
END IF


C1=ConeRadiusAngle(Axis_line,R1,Cone_angle,Astart,Angle,Direction)

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

Leave:!

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