
! script name: pksolids.d/pkcylinder
! solids: construct a cylinder solid

!A
!A NAME:
!A
!A 	Solid Cylinder
!A
!A DESCRIPTION:
!A
!A	This function constructs a cylinder of a known radius and length.
!A	The center of the bottom of the cylinder and the direction of
!A	the axis are specified.
!A
!B INSTRUCTIONS:
!B
!B 	RADIUS: Enter the radius of the cylinder to be constructed.
!B
!B	LENGTH: Enter the length of the cylinder. 
!B	
!B	LOCATION POINT: Input the location of the bottom of the cylinder.
!B
!B	AXIS DIRECTION POINT: Input a point specifing the direction of
!B				the cylinder axis.
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: cylinder  ")

DIM Destination$[256]
DIM Answer$[256]

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25
	Length1= 125
ELSE
        Radius= 1
	Length1= 5
END IF

Stat= GLPlotOn
Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(Radius)
Radius=InputRadius("RADIUS")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(length1)
Length1=InputDepth("LENGTH")
IF ExitScript(Destination$) THEN Leave

Pick_location:!
Stat=DynLabel("Radius:"&VAL$(Radius)&":Length:"&VAL$(Length1))
Stat=SetInputFormat("n4","")
Ps=XyzInput("LOCATION POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave
Stat= SetLastPoint(Ps)

Stat=SetInputFormat("n4","")
Pe=XyzInput("AXIS DIRECTION POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

Radius= DynBufferValue(0,Radius)
Length1= DynBufferValue(1,Length1)
WPKClearErrorFlag
C1=WPKCylinder(Ps,Pe,Radius,Length1)

Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)

ActivateUndo
Stat= AdvanceUndoNumber("solid cylinder")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_location

Leave:!
Stat=DynLabel("")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
