The Cylinder

You add a cylinder to a drawing using the AddCylinder method. The base of the cylinder lies in a plane parallel to the WCS XY plane.

Set 3DSolidObject = Object.AddCylinder(CylinderCenter, Radius, Height)

Table 9-3 presents the AddCylinder method's parameters, and Figure 9-3 shows an example of a cylinder in AutoCAD.

Table 9-3. The AddCylinder Method's Parameters


Data Type




A three-element array of doubles specifying the cylinder's center in WCS coordinates



A positive value representing the radius of the cylinder's base



A positive value representing the cylinder's height

Figure 9-3. A cylinder

The following example creates a cylinder based on user input:

Public Sub TestAddCylinder() Dim varPick As Variant Dim dblRadius As Double Dim dblHeight As Double Dim dblCenter(2) As Double Dim objEnt As Acad3DSolid

'' set the default viewpoint SetViewpoint

'' get input from user With ThisDrawing.Utility .InitializeUserInput 1

varPick = .GetPoint(, vbCr & "Pick the base center point: ") .InitializeUserInput 1 + 2 + 4, ""

dblRadius = .GetDistance(varPick, vbCr & "Enter the radius: ") .InitializeUserInput 1 + 2 + 4, ""

dblHeight = .GetDistance(varPick, vbCr & "Enter the Z height: ") End With

'' calculate center point from input dblCenter(0) = varPick(0)

dblCenter(1) = varPick(1)

'' draw the entity

Set objEnt = ThisDrawing.ModelSpace.AddCylinder(dblCenter, dblRadius, dblHeight) objEnt.Update

ThisDrawing.SendCommand "_shade" & vbCr End Sub

Was this article helpful?

0 0

Post a comment