OMG!! So simple! Thank you so much Bobby! I didn't even see that option in there. Works great now.
I wish it were that simple
See the code I posted in the drag thread, to get the ID
of a block, given its name. If you look at it, you may have
wondered why I was going through all of that, when I
could have just called Has() or the default indexer?
The reason is because of a problem in the SymbolTable
class, which is that both the default indexer and the Has()
member recognize erased symbol table record entires.
For example, if a given layer was deleted in the current editor
session, Has() will return true given its name. The default
indexer will return it, even though it's erased, and in most
cases, we don't want erased table records to be considered.
Hence, the code in that thread is what I generally use now
for testing for membership of, and accessing a non-erased
symbol table record (although I don't always remember to
use it in publicly posted sample code, mainly cause I'm too
lazy to find it, copy and paste... etc...).
Lately I've switched to a more generic version that works
for any type of symbol table:
public static ObjectId GetNonErasedTableRecordId( ObjectId TableId, string Name )
{
ObjectId id = ObjectId.Null;
using( Transaction tr = TableId.Database.TransactionManager.StartTransaction() )
{
SymbolTable table = (SymbolTable) tr.GetObject( TableId, OpenMode.ForRead );
if( table.Has( Name ) )
{
id = table[Name];
if( !id.IsErased )
return id;
foreach( ObjectId recId in table )
{
if( ! recId.IsErased )
{
SymbolTableRecord rec = (SymbolTableRecord) tr.GetObject( recId, OpenMode.ForRead );
if( string.Compare( rec.Name, Name, true ) == 0 )
return recId;
}
}
}
}
return id;
}