- 积分
- 268
- 明经币
- 个
- 注册时间
- 2008-9-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Sub aa()
Dim a As Object
Dim b As Object
Dim c As Object
Dim sset As AcadSelectionSet
Dim filterType(0) As Integer, filterData(0) As Variant
Set a = CreateObject("excel.application")
Set b = a.Workbooks.Add
Set c = b.Worksheets(1)
If Not IsNull(ThisDrawing.SelectionSets.Item("ToExcel")) Then
Set sset = ThisDrawing.SelectionSets.Item("ToExcel")
sset.Delete
End IfSet sset = ThisDrawing.SelectionSets.Add("ToExcel")
filterType(0) = 0
filterData(0) = "line,circle,point"
sset.SelectOnScreen filterType, filterData
c.range("A1") = "ObjectCount" '写入标题
c.range("B1") = sset.Count '写入数据
Dim Obj As AcadEntity, i As Long, varCP As Variant
i = 2
For Each Obj In sset
Select Case Obj.ObjectName
Case "AcDbPoint"
dd = Obj.Coordinates
c.range(("A" & i)) = i - 1 '写入对象名
c.range(("B" & i)) = dd(0)
c.range(("C" & i)) = dd(1)
c.range(("D" & i)) = dd(2)
End Select
i = i + 1
Next
a.Visible = True
End Sub
上次问过有位仁兄说红色部分缺少,所以加上,但是用的时候还是提醒未找到主键,有的时候却可以正常运行,为什么?
|
|