首页 > 其他 > 详细

从其它文档插入块

时间:2015-09-28 11:28:20      阅读:117      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!