Dim regcout As Integer Dim regionobj As Variant Dim outregion As AcadRegion
Dim Selects As AcadSelectionSet Dim p As Integer ReDim entobj(0 To entcount - 1) As AcadEntity ReDim regions(0 To regcount - 1) As Variant entcount = ThisDrawing.ModelSpace.Count
For i = 0 To entcount - 1 Set entobj(i) = ThisDrawing.ModelSpace.Item(i) '将图上图元付给图元数组 Next regionobj = ThisDrawing.ModelSpace.AddRegion(entobj) '将图元组合成区域 For i = 0 To entcount - 1 entobj(i).Delete Next regcount = ThisDrawing.ModelSpace.Count If regcount = 1 Then Set outregion = ThisDrawing.ModelSpace.Item(0) End If Do Until regcount = 1
For i = 0 To regcount - 1 Set regions(i) = ThisDrawing.ModelSpace.Item(i) Next Set outregion = regions(0) Loop For i = 1 To regcount - 1 If regions(i).Area > outregion.Area Then Set outregion = regions(i) End If Next Selects.AddItems outregion For Each entity In Selects If UCase(entity.ObjectName) = "ACDBpoint" Then p = p + 1 End If Next MsgBox p