ths_2000 发表于 2003-12-3 13:58:00

求助,如何在cad图上快速得到块参考对象?

在图形中如何快速得到块参考对象的列表?
我用modelspace.item()遍历,感觉速度太慢,是否还有别的好办法?

mccad 发表于 2003-12-3 13:59:00

用选择集,只先把块参照对象。

ths_2000 发表于 2003-12-3 14:24:00

谢谢!
选择集无法选到被冻结的层上的对象。

mccad 发表于 2003-12-3 15:06:00

没有试过怎么会知道不能选取呢?
选择集中对于全图的那个选项(acSelectionSetAll)与图层的状态无关。
看看示例吧:
Sub GetBlkRef()
    Dim ss As AcadSelectionSet
    Set ss = CreateSelectionSet
    Dim tFilter As Variant
    Dim dFilter As Variant
    BuildFilter tFilter, dFilter, 0, "Insert"
    ss.Select acSelectionSetAll, , , tFilter, dFilter
    Debug.Print ss.Count
End Sub

Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet

    Dim ss As AcadSelectionSet
   
    On Error Resume Next
    Set ss = ThisDrawing.SelectionSets(ssName)
    If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
    ss.Clear
    Set CreateSelectionSet = ss

End Function

Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
    Dim fType() As Integer, fData()
    Dim index As Long, i As Long
   
    index = LBound(gCodes) - 1
      
    For i = LBound(gCodes) To UBound(gCodes) Step 2
      index = index + 1
      ReDim Preserve fType(0 To index)
      ReDim Preserve fData(0 To index)
      fType(index) = CInt(gCodes(i))
      fData(index) = gCodes(i + 1)
    Next
    typeArray = fType: dataArray = fData
End Sub

ths_2000 发表于 2003-12-3 16:36:00

解决了。
小弟非常感谢!
页: [1]
查看完整版本: 求助,如何在cad图上快速得到块参考对象?