Results 1 to 1 of 1

Thread: Yet Another SelectionSet problem - search dynamic block references by block name

  1. #1
    Member
    Join Date
    2015-01
    Posts
    27
    Login to Give a bone
    0

    Default Yet Another SelectionSet problem - search dynamic block references by block name

    Hi all,
    maybe I miss some theoretical information about selectionsets, but the autocad vba guide (and a search in this forum) cannot point me in the right direction...

    EDIT: I should have read the "EffectiveName" autocad vba guide page better. It seems there's no way to select dynamic blocks using the block name other than selecting all the anonymous block references and looping through them. does .NET have a better approach to this? if yes, I really should consider switching to it!

    I created (well, I copied from multiple sources) a function that uses selectionsets to look for objects:
    Code:
    Public Function SelectObjects(aDrawing As AcadDocument, ssObs As AcadSelectionSet, spObjectType As String, Optional spName As String = "*", Optional spLayer As String = "*", Optional spVisible As Integer = 0, Optional spSpace As Integer = 0) As Long
        Dim FilterType(0 To 4) As Integer
        Dim FilterData(0 To 4) As Variant
        Dim sNumber As String
        FilterType(0) = 0: FilterData(0) = spObjectType
        FilterType(1) = 2: FilterData(1) = spName
        FilterType(2) = 8: FilterData(2) = spLayer
        FilterType(3) = 60: FilterData(3) = spVisible '0=visible, 1=invisible
        FilterType(4) = 67: FilterData(4) = spSpace '0= modelspace, 1=paperspace
        On Error Resume Next 'ignore errors if SSET doesn't exist
        aDrawing.SelectionSets.Item("SSET").Delete
        On Error GoTo SOLErrorHandler
        Set ssObs = aDrawing.SelectionSets.Add("SSET")
        ssObs.Select acSelectionSetAll, , , FilterType, FilterData
        SelectObjects = ssObs.Count
        Exit Function
    SOLErrorHandler:
        Err.Clear
        SelectObjects = 0
    End Function ' SelectObjects()
    I need to select dynamic block references whose block name follows a pattern like "*_CLASS*_EDIT*" (using quickselect with that pattern correctly gives me what I want), but
    Code:
    SelectObjects(acadDoc, acadSelection, "INSERT", "*_CLASS*_EDIT*", "0", 0, 0)
    gives me nothing (returns 0).
    Code:
    SelectObjects(acadDoc, acadSelection, "INSERT", "*_CLASS*_EDIT*,`*U*", "0", 0, 0)
    instead, gives me all the unnamed block references (along with what I'm looking for), but it defeats the entire purpose of the selection set filter.
    In any case I check for the effectivename of the block reference to make sure I'm handling the correct one, but since I have to run this code on ~1000 drawings, and there are at most 2 block references I need over about 30 block references found, I'd waste precious computing time (and work hours waiting for the macro to complete ).
    How can I fix this?
    Thanks for the attention!
    Last edited by a.ghensi689507; 2015-03-20 at 03:17 PM.

Similar Threads

  1. Select Block with XDATA by selectionset method
    By ptlong04x1 in forum VBA/COM Interop
    Replies: 1
    Last Post: 2011-07-04, 12:29 PM
  2. Replies: 2
    Last Post: 2011-05-23, 12:03 PM
  3. Replies: 9
    Last Post: 2011-02-26, 03:48 AM
  4. need to search for dynamic block attribute like quick select
    By USMCBody in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2010-07-01, 05:48 PM
  5. dynamic block references itself
    By jledgewood in forum AutoCAD Customization
    Replies: 6
    Last Post: 2010-04-21, 06:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •