//StartTransaction
using (Transaction tr = db.TransactionManager.StartTransaction()) {
BlockTableRecord btr =
(BlockTableRecord) tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
foreach (var id in acSSet) {
if (AssocArray.IsAssociativeArray(id)) {
//DBObject obj = tr.GetObject(id, OpenMode.ForRead);
AssocArray assocArray = AssocArray.GetAssociativeArray(id);
//Original entities
ObjectIdCollection soursItemIds = assocArray.SourceEntities;
//get extents of the original
Extents3d extents = new Extents3d();
foreach (ObjectId itemId in soursItemIds) {
Entity ent = tr.GetObject(itemId, OpenMode.ForRead) as Entity;
extents.AddExtents(ent.GeometricExtents);
}
ItemLocator[] itemLocators = assocArray.getItems(true);
for (int i = 0; i < itemLocators.Length; i++) {
ItemLocator itemLocator = itemLocators[i];
var trasform = assocArray.GetItemTransform(itemLocator);
//get extents of the original
Extents3d arrExtents = new Extents3d(extents.MinPoint, extents.MaxPoint);
arrExtents.TransformBy(trasform);
try {
Entity line = DrawExtents(arrExtents);
btr.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
} catch {
acDocEd.WriteMessage("\nUnable to draw the bounds.");
}
}
}
}