Syncing Block references with Deleted Attributes

Discussion in 'AutoCAD' started by Chris Shoemaker, Mar 22, 2005.

  1. Allright, here's one for ya: Let's say we have a block that's defined with
    some attributes. Let's say someone goes in and deletes the attribute
    definitions from the block. The trouble becomes that the block references in
    the drawing still display the attribute information, and you can't launch
    battman to sync all the references because the block definition no longer
    contains any attributes? How can you sync all the references to the
    un-attributed version?

    -Chris
     
    Chris Shoemaker, Mar 22, 2005
    #1
  2. Chris Shoemaker

    Oberer Guest

    Chris,
    Which version are you on?
    I tried to duplicate your scenario in 2k2 and had difficulty.
    I created a simple block (a circle with one attribute).
    I then copied the block
    I then refedited the original block to delete the attribute.
    After that, acad acted a little weird (graphically), but i was allowed to use BATTMAN...

    What am I missing?
    How are your users modifying the block(s)?
     
    Oberer, Mar 22, 2005
    #2
  3. Chris Shoemaker

    Jeff Mishler Guest

    Here's a quickie Sub that takes a block name as an argument. The sole
    purpose is to remove any Attdefs from inserted blocks that are no longer in
    the the block definition.
    Code:
    Sub TestAttSync(blkName As String)
    'Requires the MS Scripting Runtime to be referenced
    Dim oBlk As AcadBlock
    Dim oblkRef As AcadBlockReference
    Dim oEnt As AcadEntity
    Dim oAttDef As AcadAttribute
    Dim oAttRef As AcadAttributeReference
    Dim vAtts As Variant
    Dim oSS As AcadSelectionSet
    Dim iCode(1) As Integer
    Dim vVal(1) As Variant
    Dim I As Integer
    
    iCode(0) = 0: vVal(0) = "INSERT"
    iCode(1) = 2: vVal(1) = blkName
    Set oSS = ThisDrawing.PickfirstSelectionSet
    oSS.Select acSelectionSetAll, , , iCode, vVal
    If oSS.Count > 0 Then
    Set oBlk = ThisDrawing.Blocks.Item(blkName)
    Dim colAtts As New Dictionary
    For Each oEnt In oBlk
    If TypeOf oEnt Is AcadAttribute Then
    Set oAttDef = oEnt
    colAtts.Add oAttDef.TagString, I
    I = I + 1
    End If
    Next oEnt
    For Each oEnt In oSS
    Set oblkRef = oEnt
    If oblkRef.HasAttributes Then
    vAtts = oblkRef.GetAttributes
    For I = 0 To UBound(vAtts)
    Set oAttRef = vAtts(I)
    If Not colAtts.Exists(oAttRef.TagString) Then
    oAttRef.Delete
    End If
    Next I
    End If
    Next oEnt
    End If
    End Sub
    
     
    Jeff Mishler, Mar 22, 2005
    #3
  4. This is in Acad2005, using the "edit-in-place" option, and I think it
    behaved the same way in 2004. For me anyway :) I know we'll get drawings in
    here that have it done and i've been looking for a way to easily clean them
    up.

    -Chris
     
    Chris Shoemaker, Mar 22, 2005
    #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.