
! script name: vpksolids.d/vpkconeangle
! var_solids: construct cone defined by an angle

!A
!A NAME:
!A
!A 	Solid Cone: Angle	VARIATIONAL
!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

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

DIM Destination$[256]
DIM Answer$[256]
DIM Sradius_var$[256]
DIM Eradius_var$[256]
DIM Length_var$[256]
DIM Cone_angle$[256]
DIM Name$[256]
DIM Axis_line$[256]

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        R1= 25
ELSE
        R1= 1
END IF
Cone_angle=30.0

Stat= GLPlotOn
Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(R1)
R1=InputRadius("STARTING RADIUS")
IF ExitScript(Destination$) THEN Leave
No_sradius_var= LastVariableInput(Sradius_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
        IF NOT ValidDependency(C1) THEN Cloop
        No_sradius_var=0
        Stat= EntityNameCheck(C1,Sradius_var$)
END IF

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
No_cangle_var= LastVariableInput(Cone_angle$)


Pick_axis:!
Stat=SetInputFormat("n4","")
Axis_line=PickSpecificEnt("PICK AXIS LINE",WsPickLines)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Axis_line) THEN Pick_axis
Stat= EntityNameCheck(Axis_line,Axis_line$)

T=LastPickPara
IF T<=0.5 THEN
        Direction= WsForward
ELSE
        Direction= WsReverse
END IF


WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("CONE: Radius angle axis line")
IF No_sradius_var THEN
        V1= FreeParameter("Start Radius",R1)
ELSE
        V1= FreeParameter("Start Radius",Sradius_var$)
END IF
IF No_cangle_var THEN
        V2= FreeParameter("Cone Angle",Cone_angle)
ELSE
        V2= FreeParameter("Cone Angle",Cone_angle$)
END IF
C1=ConeRadiusAngle(Axis_line$,V1,V2,0,360,Direction)
RecordFunctionOff
IF ValidGeometry(C1) THEN
        Make_record= WsTrue
        RecordFunctionOn
        Pkbody=WPKBasicSolid(C1)
        Stat= WPKNameBody(Pkbody,Name$)
        Stat= WPKSetBodyParent(Pkbody)
        Stat= DeleteEntity(C1,WsTrue)
        RecordFunctionOff
ELSE
        Make_record= WsFalse
END IF
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

IF Make_record= WsFalse THEN
        DelLastVarRecord
ELSE
        Stat= WPKSolidRecordOn(Curr_record)
        ActivateUndo
        Stat= AdvanceUndoNumber("solid cone")
        Stat= AddItemToUndo(WsUBPKSessionMark)
        Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
        WPKErrorCheck
END IF
GOTO Cloop

Leave:!

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