
! script name: vsolids.d/circylinder
! var_topic: construct cylinder defined by a circle and length

!A
!A NAME:
!A
!A 	Cylinder: Circle	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a cylinder of specified length and the circle
!A 	picked will be used as one end of the cylinder and will determine the
!A 	radius and orientation of the cylinder.
!A
!A~ image location - images/circylinder.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK CIRCLE: Pick the circle to be used as one end of the cylinder
!B 		to be constructed.
!B
!B 	LENGTH: Enter the length of the cylinder to be constructed.
!B
!C NOTES:
!C
!C 	The U contours of a cylinder are the circles and the V contours are
!C 	the lines.
!C

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

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

Units= CurrentUnits
IF Units= WsMetric THEN
        Length= 100
ELSE
        Length= 5
END IF

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

ActivateUndo
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= GenerateVarName(WsCylSolidEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CYLINDER: Circle")
Stat= SetRecDelLastExec
IF No_length_var THEN
        V1= FreeParameter("Length",Length)
ELSE
        V1= FreeParameter("Length",Length_var$)
END IF
C1=CircleCylinder(Circle$,V1)
Stat= NameEntity(C1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(C1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("cylinder")
	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
