27 | 07 | 2017

Extrude Region

The code below creates a 2dregion and extrudes the shape. 

Sub Example_AddExtrudedSolid()
    ' This example extrudes a solid from a region.
    ' The region is created from an arc and a line.
    
    Dim curves(0 To 1) As AcadEntity

    ' Define the arc
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    Dim startAngle As Double
    Dim endAngle As Double
    centerPoint(0) = 5#: centerPoint(1) = 3#: centerPoint(2) = 0#
    radius = 2#
    startAngle = 0
    endAngle = 3.141592
    Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngle, endAngle)
    
    ' Define the line
    Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)
        
    ' Create the region
    Dim regionObj As Variant
    regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
    
    ' Define the extrusion
    Dim height As Double
    Dim taperAngle As Double
    height = 3
    taperAngle = 0
    
    ' Create the solid
    Dim solidObj As Acad3DSolid
    Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolid(regionObj(0), height, taperAngle)
    
    ' Change the viewing direction of the viewport
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
    ThisDrawing.ActiveViewport.Direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
        
End Sub

The result is a shape like the image below:

Extrude Region Sample

Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2311534
Latest Articles