after exploding table,
File can not be saved, show the error.
after audit command. File can be saved.
but audit command show 0 erorrs;
sorry for my bad Eng (google.transalate) :ugly:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using System.Diagnostics;
namespace SKBS.SimplifyDWG.routines
{
public class ExplodeRoutines
{
public static void Explode(ObjectId entId)
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acDB = acDoc.Database;
using (Transaction acTrans = acDB.TransactionManager.StartTransaction())
{
Entity currEnt = acTrans.GetObject(entId, OpenMode.ForWrite) as Entity;
BlockTableRecord ownerBTR = acTrans.GetObject(currEnt.OwnerId, OpenMode.ForWrite) as BlockTableRecord;
#region Table explode
if (currEnt
.GetType() == typeof(Table
)) {
Table currTable = (Table)currEnt;
DBObjectCollection tableExplodedobjects
= new DBObjectCollection
(); currTable.Explode(tableExplodedobjects);
foreach (DBObject tableEntite in tableExplodedobjects)
{
bool add = true;
if (tableEntite
.GetType() == typeof(Line
)) {
Line acLine = (Line)tableEntite;
if (acLine.ColorIndex == 8 || !acLine.Visible)
{
add = false;
}
}
Entity addedEnt = (Entity)tableEntite;
ownerBTR.AppendEntity(addedEnt);
Debug.WriteLine("object " + addedEnt.GetType().Name+":"+addedEnt.Id);
acTrans.AddNewlyCreatedDBObject(addedEnt, add);
}
Debug.WriteLine("ExplodeTableFinish");
BlockTableRecord acTablerecord = acTrans.GetObject(((BlockReference)currEnt).BlockTableRecord, OpenMode.ForWrite) as BlockTableRecord;
currEnt.Erase();
acTablerecord.Erase();
}
#endregion
#region BrfExplode
else if (currEnt
.GetType() == typeof(BlockReference
)) {
}
#endregion
acTrans.Commit();
}
}
}
}