We need to iterate through the registered application symbol table of the current database from time to time. Here is some succinct and good code in C# to do so.
[CommandMethod("RegAppIterator")]
public static void RegAppIterator_Method()
{
Database database = HostApplicationServices.WorkingDatabase;
using (Transaction transaction = database.TransactionManager.StartTransaction())
{
SymbolTable symTable = (SymbolTable)transaction.GetObject(database.RegAppTableId, OpenMode.ForRead);
foreach (ObjectId id in symTable)
{
RegAppTableRecord symbol = (RegAppTableRecord)transaction.GetObject(id, OpenMode.ForRead);
//TODO: Access to the symbol
MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage(string.Format("\nName: {0}", symbol.Name));
}
transaction.Commit();
}
}
If the command is run, something like the following may be printed out to the command line window.
Command: RegAppIterator
Name: ACAD
Name: CONTENTBLOCKDESCRIPTION
Name: CONTENTBLOCKICON
Name: CONTENTTABDATA
Name: CONTENTCURRENTTAB
Name: ACAD_PSEXT
Name: AcAecLayerStandard
Name: ACAD_EXEMPT_FROM_CAD_STANDARDS
Name: PE_URL
Name: ACAD_DSTYLE_DIMTEXT_FILL
Name: DCO15
Name: AcDbBlockRepETag
Name: AcDbDynamicBlockTrueName
Name: AcDbDynamicBlockGUID
Name: AcDbBlockRepBTag
Name: ACAD_MLEADERVER
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides various wizards, coders, and widgets to help program AutoCAD addins in C#, VB.NET or even C++/CLI.
Recent Comments