Still True? Can't filter blocks by attribute value?

Discussion in 'AutoCAD' started by Dan, Oct 25, 2004.

  1. Dan

    Dan Guest

    I want to do the same thing, but have yet to find any other information.


    Thanks,
    Dan
     
    Dan, Oct 25, 2004
    #1
  2. Still true. To be fair, you can't do it with AutoLISP or ObjectARX
    either.
     
    Frank Oquendo, Oct 25, 2004
    #2
  3. Dan

    Dan Guest

    Other methods?

    How about calling a GlobalEdit on each attribute in a selected block?
    How could this be done?

    Puzzled,
    Dan
     
    Dan, Oct 25, 2004
    #3
  4. Dan

    Dan Guest

    How about creating a selection set based up find/replace? Can this be done.
    Sting value = "B3"
    LAYER = "marks"
     
    Dan, Oct 25, 2004
    #4
  5. Dan

    Doug Broad Guest

    Probably the fastest:
    Select blocks with attributes and then iterate the selection set.
     
    Doug Broad, Oct 25, 2004
    #5
  6. Dan

    Dan Guest

    Situation:

    I have 150+ blocks


    Blockname: PMark
    Att0:B23
    Att1:A
    Att2:4
    Att3:3
    Att4:3
    Att5:6

    I have figured out how to have a user select desired block, the all
    attribute are placed into a userform to be edited. I then want all "B23"
    PMARK blocks to updated.

    Anyone have a good idea of how to handle this?

    Manually, a drafter would do a global edit on each of the attributes. I am
    trying to speed up the process since there are so many. Thanks.
    Dan
     
    Dan, Oct 26, 2004
    #6
  7. Dan

    Matt W Guest

    Sounds like you're trying to make a mountain out of the proverbial mole
    hill.

    Why not just use QSELECT, block name = PMARK.
    This will grab all blocks named PMARK. Then type FIND at the command line,
    then replace B23 with whatever.
    This will do your "global" editting of block atts.

    It'll take you more time to "automate" this process than it's probably
    worth.

    I use QSELECT all the time (and sometimes SELECT SIMILAR) to do a
    find/replace on block attributes.

    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    | Situation:
    |
    | I have 150+ blocks
    |
    |
    | Blockname: PMark
    | Att0:B23
    | Att1:A
    | Att2:4
    | Att3:3
    | Att4:3
    | Att5:6
    |
    | I have figured out how to have a user select desired block, the all
    | attribute are placed into a userform to be edited. I then want all "B23"
    | PMARK blocks to updated.
    |
    | Anyone have a good idea of how to handle this?
    |
    | Manually, a drafter would do a global edit on each of the attributes. I
    am
    | trying to speed up the process since there are so many. Thanks.
    | Dan
    |
    | | > Probably the fastest:
    | > Select blocks with attributes and then iterate the selection set.
    | >
    | >
    | | > > Other methods?
    | > >
    | > >
    | >
    | >
    |
    |
     
    Matt W, Oct 26, 2004
    #7
  8. Dan

    Dan Guest

    Thanks for your suggestion Matt.

    Thant works if I only wanted to change B23, but what we will be doing all
    the time is leaving B23, and changing the 6-9 attributes under it, so I
    would still have to do a global edit manually, because I cannot do a search
    for "A", or "1", etc.

    This is my problem. Not sure of the approach.

    Thanks again.

    Dan
     
    Dan, Oct 26, 2004
    #8
  9. Dan

    Matt W Guest

    This may not be the most graceful code, but I've used this to mass-modify
    some of our blocks.
    This will search the drawing for block refs called TEST_BLOCK_NAME and if it
    has an attribute def called ATT1 - ATT7, then the text for those attributes
    (regardless of what's there now) will be changed to, in this case, REPLACED
    VALUE 1 - 7.

    Take a look at it. Maybe you can use it.

    Code:
    Option Explicit
    
    Public Sub Attribute_Update()
    Dim varAtts() As AcadAttributeReference
    Dim objBlock As AcadBlockReference
    Dim ssSet As AcadSelectionSet
    Dim FilterType(1) As Integer
    Dim FilterData(1) As Variant
    Dim obj As AcadEntity
    Dim i As Integer
    
    Set ssSet = vbdPowerSet("BlockCount")
    
    FilterType(0) = 0
    FilterData(0) = "Insert"
    FilterType(1) = 2
    FilterData(1) = "TEST_BLOCK_NAME"
    
    ssSet.Select acSelectionSetAll, , , FilterType, FilterData
    Dim x As Integer
    x = 1
    For Each obj In ssSet
    Set objBlock = obj
    If obj.HasAttributes Then
    varAtts = obj.GetAttributes
    For i = LBound(varAtts) To UBound(varAtts)
    If UCase$(varAtts(i).TagString) = "ATT1" Then
    varAtts(i).TextString = "REPLACED VALUE 1"
    End If
    If UCase$(varAtts(i).TagString) = "ATT2" Then
    varAtts(i).TextString = "REPLACED VALUE 2"
    End If
    If UCase$(varAtts(i).TagString) = "ATT3" Then
    varAtts(i).TextString = "REPLACED VALUE 3"
    End If
    If UCase$(varAtts(i).TagString) = "ATT4" Then
    varAtts(i).TextString = "REPLACED VALUE 4"
    End If
    If UCase$(varAtts(i).TagString) = "ATT5" Then
    varAtts(i).TextString = "REPLACED VALUE 5"
    End If
    If UCase$(varAtts(i).TagString) = "ATT6" Then
    varAtts(i).TextString = "REPLACED VALUE 6"
    End If
    If UCase$(varAtts(i).TagString) = "ATT7" Then
    varAtts(i).TextString = "REPLACED VALUE 7"
    End If
    Next i
    End If
    obj.Update
    Next obj
    End Sub
    
    Public Function vbdPowerSet(strName As String) As AcadSelectionSet
    Dim objSelSet As AcadSelectionSet
    Dim objSelCol As AcadSelectionSets
    
    Set objSelCol = ThisDrawing.SelectionSets
    For Each objSelSet In objSelCol
    If objSelSet.Name = strName Then
    objSelSet.Delete
    Exit For
    End If
    Next
    Set objSelSet = ThisDrawing.SelectionSets.Add(strName)
    Set vbdPowerSet = objSelSet
    End Function
    
    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    | Thanks for your suggestion Matt.
    |
    | Thant works if I only wanted to change B23, but what we will be doing all
    | the time is leaving B23, and changing the 6-9 attributes under it, so I
    | would still have to do a global edit manually, because I cannot do a
    search
    | for "A", or "1", etc.
    |
    | This is my problem. Not sure of the approach.
    |
    | Thanks again.
    |
    | Dan
    | | > Sounds like you're trying to make a mountain out of the proverbial mole
    | > hill.
    | >
    | > Why not just use QSELECT, block name = PMARK.
    | > This will grab all blocks named PMARK. Then type FIND at the command
    | line,
    | > then replace B23 with whatever.
    | > This will do your "global" editting of block atts.
    | >
    | > It'll take you more time to "automate" this process than it's probably
    | > worth.
    | >
    | > I use QSELECT all the time (and sometimes SELECT SIMILAR) to do a
    | > find/replace on block attributes.
    | >
    | > --
    | > I support two teams: the Red Sox and whoever beats the Yankees.
    | >
    | >
    | > | > | Situation:
    | > |
    | > | I have 150+ blocks
    | > |
    | > |
    | > | Blockname: PMark
    | > | Att0:B23
    | > | Att1:A
    | > | Att2:4
    | > | Att3:3
    | > | Att4:3
    | > | Att5:6
    | > |
    | > | I have figured out how to have a user select desired block, the all
    | > | attribute are placed into a userform to be edited. I then want all
    | "B23"
    | > | PMARK blocks to updated.
    | > |
    | > | Anyone have a good idea of how to handle this?
    | > |
    | > | Manually, a drafter would do a global edit on each of the attributes.
    I
    | > am
    | > | trying to speed up the process since there are so many. Thanks.
    | > | Dan
    | > |
    | > | | > | > Probably the fastest:
    | > | > Select blocks with attributes and then iterate the selection set.
    | > | >
    | > | >
    | > | | > | > > Other methods?
    | > | > >
    | > | > >
    | > | >
    | > | >
    | > |
    | > |
    | >
    | >
    |
    |
     
    Matt W, Oct 26, 2004
    #9
  10. Dan

    Dan Guest

    Thanks Matt,
    That gives me a good Idea. I appreciate the code.
    I think I can use it, and manipulate the variables to be given value by the
    user in a form, and then past on to all the blocks, if they contain the
    correct att(0).
    I will work on it.

    Dan


     
    Dan, Oct 26, 2004
    #10
  11. Dan

    Matt W Guest

    Glad I could help.

    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    | Thanks Matt,
    | That gives me a good Idea. I appreciate the code.
    | I think I can use it, and manipulate the variables to be given value by
    the
    | user in a form, and then past on to all the blocks, if they contain the
    | correct att(0).
    | I will work on it.
    |
    | Dan
    |
    |
    | | > This may not be the most graceful code, but I've used this to
    mass-modify
    | > some of our blocks.
    | > This will search the drawing for block refs called TEST_BLOCK_NAME and
    if
    | it
    | > has an attribute def called ATT1 - ATT7, then the text for those
    | attributes
    | > (regardless of what's there now) will be changed to, in this case,
    | REPLACED
    | > VALUE 1 - 7.
    | >
    | > Take a look at it. Maybe you can use it.
    | >
    | >
    Code:
    | > Option Explicit
    | >
    | > Public Sub Attribute_Update()
    | >     Dim varAtts() As AcadAttributeReference
    | >     Dim objBlock As AcadBlockReference
    | >     Dim ssSet As AcadSelectionSet
    | >     Dim FilterType(1) As Integer
    | >     Dim FilterData(1) As Variant
    | >     Dim obj As AcadEntity
    | >     Dim i As Integer
    | >
    | >     Set ssSet = vbdPowerSet("BlockCount")
    | >
    | >     FilterType(0) = 0
    | >     FilterData(0) = "Insert"
    | >     FilterType(1) = 2
    | >     FilterData(1) = "TEST_BLOCK_NAME"
    | >
    | >     ssSet.Select acSelectionSetAll, , , FilterType, FilterData
    | >     Dim x As Integer
    | >     x = 1
    | >     For Each obj In ssSet
    | >         Set objBlock = obj
    | >         If obj.HasAttributes Then
    | >             varAtts = obj.GetAttributes
    | >             For i = LBound(varAtts) To UBound(varAtts)
    | >                 If UCase$(varAtts(i).TagString) = "ATT1" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 1"
    | >                 End If
    | >                 If UCase$(varAtts(i).TagString) = "ATT2" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 2"
    | >                 End If
    | >                 If UCase$(varAtts(i).TagString) = "ATT3" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 3"
    | >                 End If
    | >                 If UCase$(varAtts(i).TagString) = "ATT4" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 4"
    | >                 End If
    | >                 If UCase$(varAtts(i).TagString) = "ATT5" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 5"
    | >                 End If
    | >                 If UCase$(varAtts(i).TagString) = "ATT6" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 6"
    | >                 End If
    | >                 If UCase$(varAtts(i).TagString) = "ATT7" Then
    | >                     varAtts(i).TextString = "REPLACED VALUE 7"
    | >                 End If
    | >             Next i
    | >         End If
    | >         obj.Update
    | >     Next obj
    | > End Sub
    | >
    | > Public Function vbdPowerSet(strName As String) As AcadSelectionSet
    | >     Dim objSelSet As AcadSelectionSet
    | >     Dim objSelCol As AcadSelectionSets
    | >
    | >     Set objSelCol = ThisDrawing.SelectionSets
    | >     For Each objSelSet In objSelCol
    | >         If objSelSet.Name = strName Then
    | >             objSelSet.Delete
    | >             Exit For
    | >         End If
    | >     Next
    | >     Set objSelSet = ThisDrawing.SelectionSets.Add(strName)
    | >     Set vbdPowerSet = objSelSet
    | > End Function
    | > 
    | >
    | > --
    | > I support two teams: the Red Sox and whoever beats the Yankees.
    | >
    | >
    | > | > | Thanks for your suggestion Matt.
    | > |
    | > | Thant works if I only wanted to change B23, but what we will be doing
    | all
    | > | the time is leaving B23, and changing the 6-9 attributes under it, so
    I
    | > | would still have to do a global edit manually, because I cannot do a
    | > search
    | > | for "A", or "1", etc.
    | > |
    | > | This is my problem. Not sure of the approach.
    | > |
    | > | Thanks again.
    | > |
    | > | Dan
    | > | | > | > Sounds like you're trying to make a mountain out of the proverbial
    | mole
    | > | > hill.
    | > | >
    | > | > Why not just use QSELECT, block name = PMARK.
    | > | > This will grab all blocks named PMARK. Then type FIND at the
    command
    | > | line,
    | > | > then replace B23 with whatever.
    | > | > This will do your "global" editting of block atts.
    | > | >
    | > | > It'll take you more time to "automate" this process than it's
    probably
    | > | > worth.
    | > | >
    | > | > I use QSELECT all the time (and sometimes SELECT SIMILAR) to do a
    | > | > find/replace on block attributes.
    | > | >
    | > | > --
    | > | > I support two teams: the Red Sox and whoever beats the Yankees.
    | > | >
    | > | >
    | > | > | > | > | Situation:
    | > | > |
    | > | > | I have 150+ blocks
    | > | > |
    | > | > |
    | > | > | Blockname: PMark
    | > | > | Att0:B23
    | > | > | Att1:A
    | > | > | Att2:4
    | > | > | Att3:3
    | > | > | Att4:3
    | > | > | Att5:6
    | > | > |
    | > | > | I have figured out how to have a user select desired block, the
    all
    | > | > | attribute are placed into a userform to be edited. I then want
    all
    | > | "B23"
    | > | > | PMARK blocks to updated.
    | > | > |
    | > | > | Anyone have a good idea of how to handle this?
    | > | > |
    | > | > | Manually, a drafter would do a global edit on each of the
    | attributes.
    | > I
    | > | > am
    | > | > | trying to speed up the process since there are so many. Thanks.
    | > | > | Dan
    | > | > |
    | > | > | | > | > | > Probably the fastest:
    | > | > | > Select blocks with attributes and then iterate the selection
    set.
    | > | > | >
    | > | > | >
    | > | > | | > | > | > > Other methods?
    | > | > | > >
    | > | > | > >
    | > | > | >
    | > | > | >
    | > | > |
    | > | > |
    | > | >
    | > | >
    | > |
    | > |
    | >
    | >
    |
    |
     
    Matt W, Oct 26, 2004
    #11
  12. Dan

    Dan Guest

    Thank you all for the support.
    I have learned very much from this group.
    (Still VERY new to VBA)

    Well, here is the break down of my solution.

    As far as I know, you can not filter all blockreferences that have
    attributes with
    a certain tagstring attached to them.

    So I had wrote the app to allow the user to select the desired block to
    edit, which creates a selection set, and adds the block to it.

    Blockname: PMark
    Att0:B23
    Att1:A
    Att2:4
    Att3:3
    Att4:3
    Att5:6

    Then I set a variable(mystring) = to att0(B23)

    Then I cycled through all the objects, looking for a AcDbBlockReference,
    then for PMark, if PMark then get atts, If att0 = variable(B23), Then add
    object to the selectionset.
    A form pulls up with all the atts, and a user can modify them all in one
    shot, then all blocks are globally edited in one quick sweep, one form,
    Done!

    With this concept, you should be able to tailor code for your specific
    filter of block's attstrings.

    Thanks again Everyone,
    Dan
     
    Dan, Oct 28, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.