.NET

Reply
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 11 of 13 (121 Views)

Re: Get specified attribute from block without loop.

08-10-2012 04:19 PM in reply to: chiefbraincloud

chiefbraincloud wrote:

 

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.

 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 12 of 13 (113 Views)

Re: Get specified attribute from block without loop.

08-10-2012 06:22 PM in reply to: chiefbraincloud

chiefbraincloud wrote:

 

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..

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 13 of 13 (98 Views)

Re: Get specified attribute from block without loop.

08-11-2012 04:17 AM in reply to: GrzesiekGP

Hello!
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?

 

Thanks.

 

Have you played with DATAEXTRACTION command ?

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community