Hi Jeff,
Recently you helped me with adding/deleting a block to/from an dwg [not open] via dbxThanx. Now, i've cooked this code to attach an attribute to a block in active drawing:
Thanks for any help.
Youre welcome! I'm glad you found it useful.
Now you are getting into the fun stuff! As you know, you can't call a command in a dbxDoc so first you need to add the attribute to the block definition, which your code would do just fine using a dbxDoc in place of the ActiveDoc.
Next, step through ALL objects on ALL layouts, checking to see if the object is an Insert, and if it is, is it the block of interest to you. If it is, there are a couple of ways to attack the next part.
Option 1: collect the insertion point, layer, layout block it reides in, rotation angle, etc., and most importantly the attributes in the blockreference, create a list of dotted pairs ("tagstring" . "textstring"), delete the block and re-insert it setting all of the data you saved from the original, then reset the new attribute values to match the old using the list you created. Finally change the new attribute to the desired value.
Option 2: Nevermind, I can't think of an option 2...resort to option 1
If you need help with the code for this just say so.