AddRegion Method (ActiveX)

Creates a region from a set of entities. The given entities must form a closed coplanar region.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddRegion(ObjectList)
object

Type: Block, ModelSpace, PaperSpace

The objects this method applies to.

ObjectList

Access: Input-only

Type: Variant (array of Arc, Circle, Ellipse, Line, LWPolyline, Spline objects)

The array of objects forming the closed coplanar face to be made into a region.

Return Value (RetVal)

Type: Variant (array of Region objects)

This method outputs an array of the newly created Region objects.

Remarks

This method will create a region out of every closed loop formed by the input array of curves. AutoCAD converts closed 2D and planar 3D polylines to separate regions, and then converts polylines, lines, and curves that form closed planar loops. If more than two curves share an endpoint, the resultant region might be arbitrary.

You can explode a region into the individual loops by using the Explode method. The Boolean method allows you to create composite 3D solids or regions from the intersection, union, or subtraction of a solid or region from another solid or region.

The total number of Region objects created is Ubound(objRegions) - Lbound(objRegions) + 1.

Examples

VBA:

Sub Example_AddRegion()
    ' This example creates a region 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)
    ZoomAll
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddRegion()
    ;; This example creates a region from an arc and a line.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))

    ;; Define the arc
    (setq centerPoint (vlax-3d-point 5 3 0)
          radius 2
          startAngle 0
          endAngle 3.141592)
    (setq arc (vla-AddArc modelSpace centerPoint radius startAngle endAngle))
    
    ;; Define the line
    (setq line (vla-AddLine modelSpace (vla-get-StartPoint arc) (vla-get-EndPoint arc)))

    (setq curves (vlax-make-safearray vlax-vbObject '(0 . 1)))
    (vlax-safearray-put-element curves 0 arc)
    (vlax-safearray-put-element curves 1 line)
  
    ;; Create the region
    (setq regionObj (vla-AddRegion modelSpace curves))
    (vla-ZoomAll acadObj)
)