! script name: vpksolids.d/vpkcircylinder
! var_solids: construct cylinder defined by circle, length 

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

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

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

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

ActivateUndo
Units= CurrentUnits
Length=1

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


WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("CYLINDER: Circle, Length")
IF No_length_var THEN
        V3= FreeParameter("Length",Length)
ELSE
        V3= FreeParameter("Length",Length_var$)
END IF
Pkbody=WPKCylinder(Circle_var$,V3)
Stat= WPKNameBody(Pkbody,Name$)
Stat= WPKSetBodyParent(Pkbody)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("solid cylinder, circle length")
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



