合成リージョンは、リージョンまたは 3D ソリッドの交点を取り去ったり、組み合わせたり、検出したりして作成できます。
次に、合成リージョンを押し出したり回転させたりして、複雑なソリッドを作成できます。合成リージョンを作成するには、Boolean メソッドを使用します。
あるリージョンを別のリージョンから取り去るときは、最初のリージョンから Boolean メソッドを呼出します。これが、リージョンを取り去る元のリージョンになります。たとえば、平面図でどれだけのカーペットが必要かを計算するには、床面積の外側境界線から Boolean メソッドを呼び出し、柱やカウンタなどのカーペットを敷かない領域を Boolean パラメータ リスト内のオブジェクトとして使用します。
リージョンで実行される操作は、Boolean メソッドの BooleanType パラメータによって決定されます。BooleanType パラメータは次のいずれかです。
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
Area プロパティを使って、結果のリージョンの面積を算出します。