码迷,mamicode.com
首页 > 其他好文 > 详细

从其它文档插入块

时间:2015-09-28 11:30:36      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

 

//SrcPath  源文件

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

Database srcdb = new Database(false, true);

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

//Document doc   要插入的文档,

// 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;
}

}
}

从其它文档插入块

标签:

原文地址:http://www.cnblogs.com/wangfan-0812/p/4843368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!