Public Function Boundary(ByVal Point As Variant) As AcadLWPolyline
On Error Resume Next
Dim PrevTotal As Long
PrevTotal = ThisDrawing.ModelSpace.Count
ThisDrawing.SetVariable "NOMUTT", 1 '禁止不确定的消息反馈
ThisDrawing.SendCommand "_-boundary" & vbCr & Point(0) & "," & Point(1) & vbCr & vbCr '调用BOUNDARY命令获取一点的边界
ThisDrawing.SetVariable "NOMUTT", 0 '恢复普通模式的消息反馈
If ThisDrawing.ModelSpace.Count.Count > PrevTotal Then
Set Boundary = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)
End If
End Function
当Boundary为Nothing时表示没有生成边界,这时点不在多边形内部,如果生成边界时,不需要这条多义线(如仅是判断点是否在多边形内部),应该用Delete方法删除边界。