Iterating through Xref

Iterating through Xref

brianchapmandesign
Collaborator Collaborator
952 Views
2 Replies
Message 1 of 3

Iterating through Xref

brianchapmandesign
Collaborator
Collaborator

Any downsides or things I need to watch out for when iterating through an xref like this? 

 

var xdb = bd.GetXrefDatabase(false);

                                if (xdb != null)

                                {
                                    using (Transaction xrt = xdb.TransactionManager.StartTransaction())
                                    {
                                        BlockTableRecord btRecord = (BlockTableRecord)xrt.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(xdb), OpenMode.ForRead);

 


"Very funny, Scotty. Now beam down my clothes.
0 Likes
Accepted solutions (1)
953 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

I'd just wrap the xref database in a using statement to insure the database is disposed when you've done with it.

using (var xdb = bd.GetXrefDatabase(false))
{
    // ...
}

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 3

brianchapmandesign
Collaborator
Collaborator

Thank you sincerely Gilles


"Very funny, Scotty. Now beam down my clothes.
0 Likes