從其它文檔插入塊

 

//SrcPath  源文件ui

String shortName = System.IO.Path.GetFileName(SrcPath);事務

Database srcdb = new Database(false, true);文檔

srcdb.ReadDwgFile(SrcPath, FileShare.Read, false, "");
srcdb.CloseInput(true);it

//Document doc   要插入的文檔,io

// Database srcdb 數據源數據

public bool InsertAllBlock(Document doc, Database srcdb)
{
using (DocumentLock doclock = doc.LockDocument())
{
using (Transaction Trans = doc.TransactionManager.StartTransaction()) // 開始事務
{
BlockTable acBlkTbl = Trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
ObjectId tmpid = doc.Database.Insert(System.Guid.NewGuid().ToString(), srcdb, true);
BlockTableRecord btr = tmpid.GetObject(OpenMode.ForWrite) as BlockTableRecord;
btr.Erase();
Trans.Commit();
return true;
}

}
}db

相關文章
相關標籤/搜索