The Extruded Solid

You create this solid by extruding a planar region along its Z-axis. You may extrude the region in a positive or negative direction, and you may taper or expand it in the extrusion direction.

Set 3DSolidObject = Object.AddExtrudedSolid(Region, Height, TaperAngle) Table 9-9 presents the AddExtrudedSolid method's parameters.

Table 9-9. The AddExtrudedSolid Method's Parameters Name Data Type Description

Region Region object A closed planar region to be extruded.

Height Double A nonzero value representing the extrusion's height. If this value is positive, the region is extruded in the OCS Z-direction. If this value is negative, the region is extruded in the -Z direction.

TaperAngle Double The angle of tapering or expansion of the extrusion given in radians. It must lie between -90 degrees and +90 degrees. Positive values taper in from the base, and negative values expand.

In Figure 9-9 you can see that the Height parameter is positive because the region is extruded in the +Z direction, and the TaperAngle parameter is negative because the object becomes wider as it's extruded.

AutoCAD won't create the extruded object if it intersects itself. In this event, AutoCAD will raise a run-time error. To avoid this possibility, you should be careful to choose the Height and TaperAngle parameters so that this doesn't occur.

Autocad 2006 Extrude

The following example creates a circular region and extrudes it into a solid based on user input:

Public Sub TestAddExtrudedSolid() Dim varCenter As Variant Dim dblRadius As Double Dim dblHeight As Double Dim dblTaper As Double Dim strInput As String Dim varRegions As Variant Dim objEnts() As AcadEntity Dim objEnt As Acad3DSolid Dim varItem As Variant

On Error GoTo Done

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

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

dblRadius = .GetDistance(varCenter, vbCr & "Indicate the radius: ")

.InitializeUserInput 1 + 2 + 4

dblHeight = .GetDistance(varCenter, vbCr & _

"Enter the extrusion height: ")

'' get the taper type

.InitializeUserInput 1, "Expand Contract None" strInput = .GetKeyword(vbCr & _

"Extrusion taper [Expand/Contract/None]: ")

'' if none, taper = 0 If strInput = "None" Then dblTaper = 0

'' otherwise, get the taper angle Else

.InitializeUserInput 1 + 2 + 4

dblTaper = .GetReal("Enter the taper angle ( in degrees): ") dblTaper = .AngleToReal(CStr(dblTaper), acDegrees)

'' if expanding, negate the angle If strInput = "Expand" Then dblTaper = -dblTaper End If End With

'' draw the entities With ThisDrawing.ModelSpace

'' draw the outer region (circle) ReDim objEnts(o)

Set objEnts(o) = .AddCircle(varCenter, dblRadius)

'' create the region varRegions = .AddRegion(objEnts) '' extrude the solid

Set objEnt = .AddExtrudedSolid(varRegions(o), dblHeight, dblTaper)

'' update the extruded solid objEnt.Update End With


If Err Then MsgBox Err.Description

'' delete the temporary geometry For Each varItem In objEnts varItem.Delete


For Each varItem In varRegions varItem.Delete


ThisDrawing.SendCommand "_shade" & vbCr End Sub

Was this article helpful?

0 0

Post a comment