- 积分
- 1309
- 明经币
- 个
- 注册时间
- 2005-1-31
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我最近编了一个可以在CAD里矩形窗选选择集的程序,但不知为什么,只成功了一次,以后再也不行了,请各位高手看看!谢谢!
Dim entss As AcadSelectionSet
frmMain.Hide
On Error Resume Next
Set xlapp = GetObject(, "excel.application")
If Err Then
Err.Clear
Set xlapp = CreateObject("excel.application")
If Err Then
Err.Clear
MsgBox ("不能运行EXCEL,请检查是否安装了EXCEL")
Exit Sub
End If
End If
aablkname = xlapp.ActiveSheet.Cells(2, 2).Value
MsgBox aablkname
Dim sco As Integer
Dim mode As Integer
mode = acSelectionSetWindow
Dim pp(0 To 11) As Double
Dim ppt1 As Variant
Dim ppt2 As Variant
ppt1 = ThisDrawing.Utility.GetPoint(, "请选择第一点!")
ppt2 = ThisDrawing.Utility.GetPoint(, "请选择第二点!")
Set entss = ThisDrawing.SelectionSets.Add("ssss1")
Call entss.Select(mode, ppt1, ppt2)
sco = entss.count '计算选择集中的对象数
MsgBox "选中对象数:" & CStr(sco) '显示对话框
For Each eent In entss
If TypeOf eent Is AcadBlockReference Then
If StrComp(eent.Name, aablkname, vbTextCompare) = 0 Then
Set acadBlkTitleRef = eent
varAttributes = acadBlkTitleRef.GetAttributes
ubo = UBound(varAttributes)
For cnt = LBound(varAttributes) To UBound(varAttributes)
For cnt1 = LBound(varAttributes) To UBound(varAttributes)
If xlapp.Worksheets("sheet1").Cells(3, cnt1 + 1).Value = varAttributes(cnt).TagString Then
xlapp.Worksheets("sheet1").Cells(ii + 4, cnt1 + 1).Value = varAttributes(cnt).TextString
Exit For
End If
Next
Next
ii = ii + 1
End If
End If
Next eent
|
|