Create Composite Regions

AutoCAD ActiveX

 
Create Composite Regions
 
 
 

You can create composite regions by subtracting, combining, or finding the intersection of regions or 3D solids. You can then extrude or revolve composite regions to create complex solids. To create a composite region, use the Boolean method.

When you subtract one region from another, you call the Boolean method from the first region. This is the region from which you want to subtract. For example, to calculate how much carpeting is needed for a floorplan, call the Boolean method from the outer boundary of the floor space and use the uncarpeted areas, such as pillars and counters, as the object in the Boolean parameter list.

Create a composite region

Sub Ch4_CreateCompositeRegions()
    ' Create two circles, one representing a room,
    ' the other a pillar in the center of the room
    Dim RoomObjects(0 To 1) As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 4
    center(1) = 4
    center(2) = 0
    radius = 2#
    Set RoomObjects(0) = ThisDrawing.ModelSpace. _
 AddCircle(center, radius)
    radius = 1#
    Set RoomObjects(1) = ThisDrawing.ModelSpace. _
 AddCircle(center, radius)
      
    ' Create a region from the two circles
    Dim regions As Variant
    regions = ThisDrawing.ModelSpace.AddRegion(RoomObjects)
      
    ' Copy the regions into the region variables for ease of use
    Dim RoundRoomObj As AcadRegion
    Dim PillarObj As AcadRegion
      
    If regions(0).Area > regions(1).Area Then
        ' The first region is the room
        Set RoundRoomObj = regions(0)
        Set PillarObj = regions(1)
    Else
        ' The first region is the pillar
        Set PillarObj = regions(0)
        Set RoundRoomObj = regions(1)
    End If
' Subtract the pillar space from the floor space to
    ' get a region that represents the total carpet area.
    RoundRoomObj.Boolean acSubtraction, PillarObj
      
    ' Use the Area property to determine the total carpet area
    MsgBox "The carpet area is: " & RoundRoomObj.Area
End Sub

Find the area of the resulting region with the Area property.