明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1762|回复: 1

请问在VBA中怎么使一个选择集只选中模型空间中可见图元?

[复制链接]
发表于 2003-4-10 08:53:00 | 显示全部楼层 |阅读模式
请问在VBA中怎么使一个选择集只选中模型空间中可见图元?
我隐藏&锁定&冻结了其他,然后使用了

FilterType = 60
FilterData = 0
sset.SelectOnScreen FilterType, FilterData

可是选不中任何图元,也没什么错误提示???
烦闷!
高手,救救我吧?
发表于 2003-4-10 19:00:00 | 显示全部楼层

你必须通过图层过滤出可见的图层,然后把这些图层做为过滤器的条件

本帖最后由 mccad 于 2003-4-10 19:00:47 编辑

Sub GetEnt()
    Dim ss As AcadSelectionSet
    Set ss = CreateSelectionSet
    Dim Ly As String
    Ly = ""
    Dim Lyer As AcadLayer
    Dim I As Integer
    Debug.Print ThisDrawing.Layers.Count
    For I = 0 To ThisDrawing.Layers.Count - 1
        Set Lyer = ThisDrawing.Layers(I)
        If Lyer.LayerOn = True Then
            Ly = Ly & Lyer.Name & ","
        End If
    Next
    Dim fType As Variant: Dim fData As Variant
    BuildFilter fType, fData, 8, Ly
    ss.Select acSelectionSetAll, , , fType, fData
    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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 18:39 , Processed in 0.174596 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表