如何提取line的两个端点坐标
如何提取line的两个端点坐标。图形中已有若干条line直线,现在要提取line的两个端点坐标。怎样实现?
看到这样的帖子有点不敢回复
不是太难,而是太容易,总感觉到提问者是不是没有表达完整自己的问题。希望楼主能从以下代码中得到帮助,若还有其它困难,请说清楚。因为都VBA基本操作,所以没加注释。Sub GetPointFromLine()
Dim Pt1 As Variant
Dim Pt2 As Variant
Dim Str As String
Dim Sel As AcadSelectionSet
On Error Resume Next
Set Sel = ThisDrawing.SelectionSets.Add("ssel")
If Err Then
Err.Clear
ThisDrawing.SelectionSets("ssel").Delete
Set Sel = ThisDrawing.SelectionSets.Add("ssel")
End If
On Error GoTo 0
Sel.SelectOnScreen
Dim obj As AcadObject
For Each obj In Sel
If obj.ObjectName = "AcDbLine" Then
Pt1 = obj.StartPoint
Pt2 = obj.EndPoint
Str = "起点:(" & Pt1(0) & "," & Pt1(1) & "," & Pt1(2) & ")" & Chr(13)
Str = Str & "终点:(" & Pt2(0) & "," & Pt2(1) & "," & Pt2(2) & ")"
MsgBox Str
End If
Next
Sel.Delete
End Sub ok!
多谢!!
页:
[1]