
! script name: vsolids.d/circone
! var_topic: 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
!C NOTES:
!C
!C 	The U contours of a cone are the circles and the V contours are
!C 	the lines.
!C

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

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

Stat= GenerateVarName(WsConeSolidEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CONE: Circle")
Stat= SetRecDelLastExec
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)
Stat= NameEntity(C1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(C1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("cone")
	Stat= AddItemToUndo(WsUBCreateMode,C1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Cloop

Leave:!
Stat=SetInputFormat("n4","")

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