既然本图中已经存在此块,可以将插入块中的重复的块改个名字
// houlinbo QQ420021327
private static void ClearReBtr( Database newdb , BlockTable bt)
{
try
{
Transaction tr = newdb.TransactionManager.StartTransaction();
using (tr)
{
BlockTable newbt = tr.GetObject(newdb.BlockTableId, OpenMode.ForWrite) as BlockTable;
foreach (ObjectId objId in newbt)
{
BlockTableRecord newbtr = tr.GetObject(objId, OpenMode.ForRead) as BlockTableRecord;
if (bt.Has(newbtr.Name) && !newbtr.Name.Equals("*Model_Space") && !newbtr.Name.Contains ("*Paper_Space"))
{
newbtr.UpgradeOpen(); //升级写打开
newbtr.Name ="*U";
}
}
}
}
catch
{ }
}