Here is a type of snippet that has got me wondering...
It creates an entire procedure. I started to build a library of helper classes with these sorts of functions. But I wasn't happy with that. I didn't want to have to learn another API on top of acad, and adt, and the .net framework. Not to mention that it would be a library under constant update, just to name a couple of things that were nagging at me.
I'm going to give this method a spin and see how it goes.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Get or create a symbol table record.</Title>
<Author>Bobby C. Jones</Author>
<Description>
Creates a function that returns an existing symbol table record, or creates it if it doesn't exist.
</Description>
<Shortcut>gc</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Keywords>
<Keyword>Autocad</Keyword>
<Keyword>Symbol Table Object</Keyword>
<Keyword>BlockTableRecord</Keyword>
<Keyword>LayerTableRecord</Keyword>
</Keywords>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>SymbolTable</ID>
<ToolTip>Replace with the proper SymbolTable type name.</ToolTip>
<Default>Block</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[
internal static ObjectId GetOrCreate$SymbolTable$TableRecord(string $SymbolTable$TableRecordName, Database targetDatabase)
{
using (Transaction trans = targetDatabase.TransactionManager.StartTransaction())
{
$SymbolTable$Table symbolTable = trans.GetObject(targetDatabase.$SymbolTable$TableId, OpenMode.ForRead) as $SymbolTable$Table;
if (!symbolTable.Has($SymbolTable$TableRecordName))
{
$SymbolTable$TableRecord symbolTableRecord = new $SymbolTable$TableRecord();
symbolTableRecord.Name = $SymbolTable$TableRecordName;
symbolTable.UpgradeOpen();
symbolTable.Add(symbolTableRecord);
symbolTable.DowngradeOpen();
trans.AddNewlyCreatedDBObject(symbolTableRecord, true);
trans.Commit();
}
return symbolTable[$SymbolTable$TableRecordName];
}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>