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

!A
!A NAME:
!A
!A 	Cone: 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~ image location - images/circone.gif
!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

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

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Circle$[256]
DIM Length_var$[256]
DIM Angle_var$[256]

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Length= 100
ELSE
        Length=5
END IF
Cone_angle=30.0

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

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
No_angle_var= LastVariableInput(Angle_var$)

WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("SHEET: cone from circle ")
IF No_length_var THEN
        V1= FreeParameter("Length",Length)
ELSE
        V1= FreeParameter("Length",Length_var$)
END IF
IF No_angle_var THEN
        V2= FreeParameter("Angle",Cone_angle)
ELSE
        V2= FreeParameter("Angle",Angle_var$)
END IF
C1=CircleCone(Circle$,V1,V2)
RecordFunctionOff
IF ValidGeometry(C1) THEN
        Make_record= WsTrue
        RecordFunctionOn
        G1=WPKMakeBsurf(C1)
        Stat= WPKNameBodyGroup(G1,Name$)
        Stat= WPKSetBodyParent(G1,1)
        Stat= DeleteEntityList(G1,C1)
        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("cone sheet")
        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
