! script name: vpksolids.d/vpkcircone
! var_solids: construct cone defined by circle, length and taper angle

!A
!A NAME:
!A
!A 	Cone: Solid cone from circle VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a cone of specified length and taper angle
!A 	using the picked circle as the start of the cone.  The picked circle
!A 	will determine the orientation of the axis line of the cone.
!A
!A
!B INSTRUCTIONS:
!B
!B 	PICK CIRCLE: Pick the circle to be used as the starting circle of the
!B 		cone.
!B
!B 	LENGTH: Enter the length of the cone to be constructed.
!B
!B 	CONE ANGLE: Enter the angle of taper of the cone.
!B
!C NOTES:
!C
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: cone defined by a circle ")

DIM Destination$[256]
DIM Answer$[256]
DIM Circle_var$[256]
DIM Length_var$[256]
DIM Cone_angle$[256]
DIM Name$[256]

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

ActivateUndo
Units= CurrentUnits
Length=1
Cone_angle=30.0

Stat= GLPlotOn
Cloop:!
Pcircle=PickSpecificEnt("PICK CIRCLE",WsPickCircles)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(pcircle) THEN Cloop
Stat= EntityNameCheck(pcircle,Circle_var$)

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Length)
Length=GetValue("LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave
No_length_var= LastVariableInput(Length_var$)

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$)


WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("CONE: Circle, Included Angle")
IF No_cangle_var THEN
        V2= FreeParameter("Cone Angle",Cone_angle)
ELSE
        V2= FreeParameter("Cone Angle",Cone_angle$)
END IF
IF No_length_var THEN
        V3= FreeParameter("Length",Length)
ELSE
        V3= FreeParameter("Length",Length_var$)
END IF
Pkbody=WPKCone(Circle_var$,V2,V3)
Stat= WPKNameBody(Pkbody,Name$)
Stat= WPKSetBodyParent(Pkbody)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("solid cone, circle angle")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck
GOTO Cloop

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



