AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides a Space Iterator coder.
It can help generate AutoCAD space (either model space or paper space; 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 Space Iterator code are set as the above screenshot, the space 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 = dbVarBefore2.TransactionManager.StartTransaction())
{
BlockTableRecord btRecord = (BlockTableRecord)transaction.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(dbVarBefore2), OpenMode.ForRead);
foreach (ObjectId id in btRecord)
{
Entity entity = (Entity)transaction.GetObject(id, OpenMode.ForRead);
//TODO: Access to the entity
}
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