You should, however, be disposing the Attribute References that you open.
Sorry, but that's not the case.
There's absolutely no need to dispose any DBObject that was opened from a transaction. If you've been reading the adndevblog, you may have misunderstood some recent advice offered there regarding disposing AutoCAD objects.
I also try not to have nested transactions, and I should have also mentioned I don't like passing around open objects, either. I always pass ObjectIds and open them in the function that is doing the work.
Hate to disagree.
I see no legitimate reason not to pass open DBObjects as parameters, especially if you follow consistent design patterns where APIs that take open DBObjects as parameters typically assume there is an active transaction that is managed at the entry point (e.g., a command method, event handler, etc).
The other problem with your idea that passing ObjectIds is preferable, is that it complicates code-reusability because APIs that take DBObjects can also accept DBObjects that are not database-resident, have no valid ObjectId, and can't be opened via GetObject().
Additionally, some events pass arguments that include open DBObjects that are not transaction-resident and can't be safely opened with a transaction from the handler of the event, further complicating reusability of APIs that require ObjectIds.
So.... If writing good sound reusable code is important, then writing APIs that take DBObjects is far better than ones that take ObjectIds, for many reasons aside from it being far more efficient..
I know how to get/set attribute within loop at block's AttributeCollection.
But I'm wonder if I can set value for specified attribute without loop. Or I always have to iterate on each attribute in block's AttributeCollection?
Have you played with DATAEXTRACTION command ?
Access a broad range of knowledge to help get the most out of your products and services.