Create Regions
From AutoCAD ActiveX
To create a region, use the AddRegion method. 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, then converts polylines, lines, and curves that form closed planar loops. If more than two curves share an endpoint, the resulting region might be arbitrary. Because of this, several regions may actually be created when using the AddRegion method. Use a variant to hold the newly created array of regions.
To calculate the total number of Region objects created, use the UBound and LBound VBA functions, as in the following example:
UBound(objRegions) - LBound(objRegions) + 1
where objRegions is a variant containing the return value from AddRegion. This statement will calculate the total number of regions created.
The following code example creates a region from a single circle.
Sub Ch4_CreateRegion()
' Define an array to hold the
' boundaries of the region.
Dim curves(0 To 0) As AcadCircle
' Create a circle to become a' boundary for the region.Dim center(0 To 2) As DoubleDim radius As Doublecenter(0) = 2center(1) = 2center(2) = 0radius = 5#Set curves(0) = ThisDrawing.ModelSpace.AddCircle _(center, radius)' Create the regionDim regionObj As VariantregionObj = ThisDrawing.ModelSpace.AddRegion(curves)ZoomAllEnd Sub