- 积分
- 3266
- 明经币
- 个
- 注册时间
- 2002-7-5
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-9-30 18:32:00
|
显示全部楼层
看到这样的帖子有点不敢回复
不是太难,而是太容易,总感觉到提问者是不是没有表达完整自己的问题。希望楼主能从以下代码中得到帮助,若还有其它困难,请说清楚。因为都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 |
|