AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides a Symbol Iterator coder.
It can help generate AutoCAD symbol (dimension style, layer, linetype, registered application, text style, UCS, view, or viewport; either from the working database or any database pointer through a good local variable or a method parameter) iteration code in no time.
If the current cursor is placed inside a method like the following:
public void IteratorTest(Database db1, Autodesk.AutoCAD.DatabaseServices.Database db2)
{
Database dbVarBefore1 = db1;
Database dbVarBefore2 = HostApplicationServices.WorkingDatabase;
//Place the cursor under
Database dbVarAfter1 = db1;
Database dbVarAfter2 = db2;
}
And if the options of the Symbol Iterator coder are set as the above screenshot, the symbol iteration code will be automatically generated as highlighted in green below.
public void IteratorTest(Database db1, Autodesk.AutoCAD.DatabaseServices.Database db2)
{
Database dbVarBefore1 = db1;
Database dbVarBefore2 = HostApplicationServices.WorkingDatabase;
//Place the cursor under
using (Transaction transaction = db2.TransactionManager.StartTransaction())
{
SymbolTable symTable = (SymbolTable)transaction.GetObject(db2.DimStyleTableId, OpenMode.ForRead);
foreach (ObjectId id in symTable)
{
DimStyleTableRecord symbol = (DimStyleTableRecord)transaction.GetObject(id, OpenMode.ForRead);
//TODO: Access to the symbol
}
transaction.Commit();
}
Database dbVarAfter1 = db1;
Database dbVarAfter2 = db2;
}
Enjoy it!
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides some cool wizards, coders and widgets to facilitate the development work using AutoCAD .NET API.
Recent Comments