
! script name: dyn_solids.d/dynaxiscone
! 3dtopic: construct cone along an axis line

!A
!A NAME:
!A
!A 	Dynamic Cone: Axis
!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.  The length of the cone is determined
!A 	by the length of the axis line picked.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING RADIUS: Enter the starting radius of the cone.
!B
!B 	ENDING RADIUS: Enter the ending radius of the cone.
!B
!B 	STARTING ANGLE ( 0 90 180 270 ): Enter the starting
!B 		angle of the cone.
!B
!B 	ANGULAR EXTENT ( 90 180 360 ): Enter the number of
!B 		degrees and the direction ( + CCW, - CW ) from
!B 		the starting angle to the ending angle.  The
!B 		angular extent determines the ending angle.
!B
!B 	AXIS START X,Y,Z: Enter the axis start point of the cone.
!B
!B 	PICK AXIS ENDPOINT: Pick the axis endpoint.
!B
!C NOTES:
!C
!C 	The U contours of a cone are the circles and the V contours
!C 	are the lines.
!C
!# see also - points.d/dyninput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: cone along an axis line ")

DIM Destination$[256]
DIM Answer$[256]
REAL Params(0:10)

Units= CurrentUnits
IF Units= WsMetric THEN
        R1= 25
        R2= 25
ELSE
        R1= 1
        R2= 1
END IF

Start:!
Stat=SetPickMask(WsPickNoSurf)
ActivateUndo
Astart= 0
Angle= 180

Dynamic_length1= GetDefault(WsDynamicLength1)
Dynamic_length2= GetDefault(WsDynamicLength2)
Dynamic_angle1= GetDefault(WsDynamicAng1Incr)
Dynamic_angle2= GetDefault(WsDynamicAng2Incr)

Dynamic_radius= GetDefault(WsDynRadiusDefault)
Dynamic_angle= GetDefault(WsDynAngleDefault)

Stat= SetDefaults(WsDynamicLength1,Dynamic_radius)
Stat= SetDefaults(WsDynamicLength2,Dynamic_radius)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle)


Cloop:!

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

Stat=SetRadiusEquals(R2)
R2=InputRadius("ENDING RADIUS")
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Astart)
Astart=InputAngle("STARTING ANGLE ( 0 90 180 270 ) ")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4b=","")
Stat=SetEqualsValue(Angle)
Angle=GetValue("ANGULAR EXTENT ( 90 180 360 ) ",Answer$)
IF ExitScript(Destination$) THEN Leave

Pick_axis:!
Ps=XyzInput("AXIS START",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ps) THEN Pick_axis

Stat=SetLastPoint(Ps)

PlotOff
Length1= (R1+R2)
Pe= PtIncrXyz(Ps,0.0,Length1,0.0)
Axis_line= LineTwoPoints(Ps,Pe)
C1=AxisLineCone(Axis_line,R1,R2,Astart,Angle,WsForward)
Stat= MakeInvisible(Axis_line)
Stat= MakeInvisible(C1)
Stat= MakeInvisible(Ps)
Stat= MakeInvisible(Pe)
PlotOn

Vnum= LastPickView
Params(0)= R1
Params(1)= R2
Params(2)= Length1
Params(3)= Astart
Params(4)= Angle
Num_params=5
Stat=SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,C1,Ps,Pe,WsDynAxisCone,"PICK AXIS ENDPOINT ",Params,Num_params)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(C1,WsTrue)
	Stat=DeleteEntity(Ps,WsTrue)
        Stat=DeleteEntity(Pe,WsTrue)
        Stat=DeleteEntity(Axis_line,WsTrue)
        IF Destination$= "BACKUP" THEN Pick_axis
        GOTO Leave
END IF

Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Axis_line)
Stat= PlotEntity(C1)

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

GOTO Pick_axis

Leave:!
Stat=SetPickMask(WsPickGeometry)
Stat= SetDefaults(WsDynamicLength1,Dynamic_length1)
Stat= SetDefaults(WsDynamicLength2,Dynamic_length2)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle1)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle2)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Axis_line)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	LOAD Destination$
END IF
END
