以下程序只考虑你的要求,没有增加一些错误的判断,自己加吧:
- Sub MakeRegion()
- Dim Ent(2) As AcadEntity
- Dim Pnt As Variant
- On Error Resume Next
- ThisDrawing.Utility.GetEntity Ent(0), Pnt, "选择第一条线:"
- ThisDrawing.Utility.GetEntity Ent(1), Pnt, "选择第二条线:"
- ThisDrawing.Utility.GetEntity Ent(2), Pnt, "选择第三条线:"
- Dim Regs As Variant
- Regs = ThisDrawing.ModelSpace.AddRegion(Ent)
- If Err Then
- Err.Clear
- ThisDrawing.Utility.Prompt vbCrLf & "选定的对象不能生成面域"
- Else
- 'Dim Reg As AcadRegion
- If IsArray(Regs) Then
- ThisDrawing.Utility.Prompt vbCrLf & "生成的面域数量:" & UBound(Regs) + 1
- 'Set Reg = Regs(0)
- Ent(0).Delete: Ent(1).Delete: Ent(2).Delete
- Else
- ThisDrawing.Utility.Prompt vbCrLf & "选定的对象不能生成面域"
- End If
- End If
- End Sub
|