Having an Issue Grabbing Blocks in a Drawing...

Discussion in 'AutoCAD' started by arsnik91, Jun 23, 2003.

  1. arsnik91

    arsnik91 Guest

    I'm trying to change all the Blocks in a drawing to a certain Layer but I must not be seeing the problem. This routine works fine with Lines and Circles but Blocks are a bit different I guess. Could someone point out what I am missing please?



    Sub BlockFind()

    Dim ssBlock As AcadSelectionSet
    Dim FilterType(0) As Integer
    Dim FilterData(0) As Variant
    Dim objSelected As Object
    Dim acBlock As AcadBlock

    Set ssBlock = ThisDrawing.SelectionSets.Add("ssTemp")
    FilterType(0) = 0
    FilterData(0) = "Block"
    ssBlock.Select acSelectionSetAll, , , FilterType, FilterData
    ssBlock.Highlight True
    For Each objSelected In ssBlock
    If TypeOf objSelected Is AcadBlock Then
    Set acBlock = objSelected
    acBlock.Layer = "Fittings"
    End If
    Next

    ThisDrawing.Regen acAllViewports

    MsgBox ("Selection set " & ssBlock.Name & " moved " & _
    ssBlock.Count & " items to the Fittings layer.")

    End Sub
     
    arsnik91, Jun 23, 2003
    #1
  2. arsnik91

    Mark Propst Guest

    oops didn't read close enough,
    as Joe said:
    FilterData(0) = "Insert"
    ....and
    Dim acBlock As AcadBlockReference
    ....and
    If TypeOf objSelected Is AcadBlockReference Then

    hopefully that should get it.
    read up on blocks and inserts in the help, that should help
     
    Mark Propst, Jun 23, 2003
    #2
  3. arsnik91

    Mark Propst Guest

    True, but with Autocad does anything ever work *exactly* as it's supposed
    to?
    At what point does error testing become redundant?
     
    Mark Propst, Jun 24, 2003
    #3
  4. arsnik91

    arsnik91 Guest

    Thank you to all that responded. With your help I was able to do what I was hoping for.
     
    arsnik91, Jun 24, 2003
    #4
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.