
! script name: vsolids.d/radcircone
! var_topic: construct cone defined by circle, length, and end radius

!A
!A NAME:
!A
!A 	Cone:  Rad: Circle	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a cone of specified length and ending radius,
!A 	using the picked circle for the starting radius.  The picked circle
!A 	will determine the orientation of the axis line of the cone.
!A
!A~ image location - images/radcircone.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK CIRCLE: Pick the circle to be used as the starting circle of
!B 		the cone.
!B
!B 	ENDING RADIUS: Enter the ending radius of the cone.
!B
!B 	LENGTH: Enter the length of the cone to be constructed.
!B
!C NOTES:
!C 	The U contours of a cone are the circles and the V contours are the
!C 	lines.
!C

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

DIM Destination$[256]
DIM Answer$[256]
DIM Circle$[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
        R2= 25
	Length= 100
ELSE
        R2= 1
	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=SetRadiusEquals(R2)
R2=InputRadius("ENDING RADIUS")
IF ExitScript(Destination$) THEN Leave
R2=ABS(R2)
No_eradius_var= LastVariableInput(Eradius_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
        IF NOT ValidDependency(C1) THEN Cloop
        No_radius_var=0
        Stat= EntityNameCheck(C1,Eradius_var$)
END IF

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

Stat= GenerateVarName(WsConeSolidEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CONE: Rad circle")
Stat= SetRecDelLastExec
IF No_eradius_var THEN
        V1= FreeParameter("End Radius",R2)
ELSE
        V1= FreeParameter("End Radius",Eradius_var$)
END IF
IF No_length_var THEN
        V2= FreeParameter("Length",Length)
ELSE
        V2= FreeParameter("Length",Length_var$)
END IF
C1=RadiusCircleCone(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:!
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
