
! script name: vpksolids.d/vpkconeaxis
! var_solids: construct cone along an axis line

!A
!A NAME:
!A
!A 	Solid Cone: Axis	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.  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 	PICK AXIS LINE: Pick the line to be used as the axis of the cone.
!B
!C NOTES:
!C
!C
!# see also - htdocs/help.d/parasolids.htm

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

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

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

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

Stat= GLPlotOn
Cloop:!
Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(R1)
R1=InputRadius("START 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

Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(R2)
R2=InputRadius("END RADIUS")
IF ExitScript(Destination$) THEN Leave
No_eradius_var= LastVariableInput(Eradius_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
        IF NOT ValidDependency(C1) THEN Cloop
        No_eradius_var=0
        Stat= EntityNameCheck(C1,Eradius_var$)
END IF


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: Axis line")
IF No_sradius_var THEN
        V1= FreeParameter("Start Radius",R1)
ELSE
        V1= FreeParameter("Start Radius",Sradius_var$)
END IF
IF No_eradius_var THEN
        V2= FreeParameter("End Radius",R2)
ELSE
        V2= FreeParameter("End Radius",Eradius_var$)
END IF
C1=AxisLineCone(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:!
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
