We need to iterate through the dimension style symbol table of the current database from time to time. Here is some succinct and good code in C# to do so.
[CommandMethod("DimStyleIterator")]
public static void DimStyleIterator_Method()
{
Database database = HostApplicationServices.WorkingDatabase;
using (Transaction transaction = database.TransactionManager.StartTransaction())
{
SymbolTable symTable = (SymbolTable)transaction.GetObject(database.DimStyleTableId, OpenMode.ForRead);
foreach (ObjectId id in symTable)
{
DimStyleTableRecord symbol = (DimStyleTableRecord)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: DimStyleIterator
Name: Standard
Name: Annotative
Name: ISO-25
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.
Posted by: |