Message 1 of 10
Can't save boolean operation to disk.
Not applicable
04-26-2019
08:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
In the following routine, while cycling through all the entities, i delete some of them and i do a boolean operation for some of them.
At the end I save the drawing with a new name. When I open the drawing, the deleted entites are gone, as they should be, but the ones which went through the boolean operation are not modified. On the screen they look like the boolean operation was successful. If i save the drawing manually, they are saved correctly.
Should I do more than committing the transaction before saving the drawing?
Thank you.
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Editor ed = acDoc.Editor;
Database acCurDb = acDoc.Database;
// LOCK DOCUMENT BEFORE TRANSACTION
using (DocumentLock docLock = acDoc.LockDocument())
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table record for read
ed.WriteMessage("\nDAP");
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
foreach (ObjectId id in acBlkTblRec)
{
Solid3d entity = (Solid3d)acTrans.GetObject(id, OpenMode.ForWrite);
ObjectId intityId = entity.ObjectId;
Extents3d ext = entity.GeometricExtents;
if ((ext.MaxPoint.X < tileMin.X)||
(ext.MinPoint.X>tileMax.X)||
(ext.MaxPoint.Y<tileMin.Y)||
(ext.MinPoint.Y>tileMax.Y)
)//if outside
{
//delete entity
entity.Erase(true);
}
else if (!((ext.MinPoint.X > tileMin.X) && (ext.MinPoint.Y > tileMin.Y) &&
(ext.MaxPoint.X < tileMax.X) && (ext.MaxPoint.Y < tileMax.Y)))//else if not completely inside
{
// start creating box
using (var box = new Solid3d())
{
box.CreateBox(250.0, 250, 800.0);
box.TransformBy(Matrix3d.Displacement(new Vector3d(tileMin.X+125.0, tileMin.Y+125.0, 0.0)));
entity.BooleanOperation(BooleanOperationType.BoolIntersect, box);
}
// end creating box
}
}
// Save the new objects to the database
acTrans.Commit();
}
ed.WriteMessage(cale + deTaiat + "\\" + deTaiat + "_" + quarter[ct] + "_" + sixteen[4 * ct + ct1] + "_SOLID.dwg");
acCurDb.SaveAs(cale + deTaiat + "\\" + deTaiat + "_" + quarter[ct] +"_" + sixteen[4*ct+ct1]+ "_SOLID.dwg", DwgVersion.Current);