呵呵,这个也可以求面积。在封闭区域内选择一点,然后生成它的边界,这个边界就是封闭的多段线,直接使用它的属性就行了。
- Sub test()
-
- ' 当前图纸的实体数目
- Dim n As Long
- n = ThisDrawing.ModelSpace.Count
-
- ' 调用BOUNDARY命令获取某一点处的边界
- Dim Pt As Variant
- Pt = ThisDrawing.Utility.GetPoint(, "指定内部点: ")
- ThisDrawing.SendCommand "_-Boundary" & vbCr & Pt(0) & "," & Pt(1) & vbCr & vbCr
-
- ' 如果存在边界,则会生成新的实体
- Dim lwpLineObj As AcadLWPolyline
- If ThisDrawing.ModelSpace.Count > n Then
- Set lwpLineObj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)
- MsgBox lwpLineObj.Area
- lwpLineObj.Delete
- Else
- MsgBox "未发现有效的边界。"
- End If
- End Sub
|