The Revolved Solid

You add a 3DSolid object representing a revolved solid, which you create by sweeping a planar region around an axis, to a drawing by using the AddRevolvedSolid method.

Set 3DSolidObject = Object.AddRevolvedSolid(Region, AxisPoint, _

AxisDirection, Angle)

Table 9-11 presents the AddRevolvedSolid method's parameters, and Figure 9-11 shows an example of a revolved solid in AutoCAD.

Table 9-11. The AddRevolvedSolid Method's Parameters

Name

Data Type

Description

Region

Region object

A closed planar region to be revolved.

AxisPoint

Variant

A three-element array of doubles specifying the center of the axis of rotation in WCS coordinates.

AxisDirection Variant

A three-element array of doubles specifying a directional vector for the axis of rotation.

Angle

Double

The angle through which the region is swept, measured in radians. You determine the positive direction of rotation by applying the arbitrary axis algorithm to AxisDirection.

Axle Point

Figure 9-11. A revolved solid

Axle Point

Figure 9-11. A revolved solid

The following example lets the user choose a closed region, which is then revolved into a solid based on user input:

Dim objShape As AcadLWPolyline Dim varPick As Variant Dim objEnt As AcadEntity Dim varPnt1 As Variant Dim dblOrigin(2) As Double Dim varVec As Variant Dim dblAngle As Double Dim objEnts() As AcadEntity Dim varRegions As Variant Dim varItem As Variant

'' set default viewpoint

SetViewpoint

'' draw the shape and get rotation from user

'' pick a shape On Error Resume Next

.GetEntity objShape, varPick, "pick a polyline shape" If Err Then

MsgBox "You did not pick the correct type of shape" Exit Sub End If On Error GoTo Done objShape.Closed = True

'' add pline to region input array

ReDim objEnts(0)

Set objEnts(0) = objShape

'' get the axis points .InitializeUserInput 1

varPnt1 = .GetPoint(, vbLf & "Pick an origin of revolution: ") .InitializeUserInput 1 varVec = .GetPoint(dblOrigin, vbLf & _ "Indicate the axis of revolution: ")

'' get the angle to revolve .InitializeUserInput 1

dblAngle = .GetAngle(, vbLf & "Angle to revolve: ") End With

'' make the region, then revolve it into a solid With ThisDrawing.ModelSpace

'' make region from closed pline varRegions = .AddRegion(objEnts)

Set objEnt = .AddRevolvedSolid(varRegions(0), varPnt1, varVec, dblAngle) objEnt.Color = acRed End With

Done:

If Err Then MsgBox Err.Description '' delete the temporary geometry For Each varItem In objEnts: varItem.Delete: Next If Not IsEmpty(varRegions) Then

For Each varItem In varRegions: varItem.Delete: Next End If

ThisDrawing.SendCommand "_shade" & vbCr End Sub