- 积分
- 11099
- 明经币
- 个
- 注册时间
- 2005-2-20
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2012-11-6 17:09:50
|
显示全部楼层
写了个c#的
public static void CloneBlock(string blockName, string fromFileName)
{
Database fromdb = new Database(false, false);
fromdb.ReadDwgFile(fromFileName, System.IO.FileShare.Read, true, "");
Database db = HostApplicationServices.WorkingDatabase;
Transaction tr = db.TransactionManager.StartTransaction();
BlockTable fromBt =(BlockTable) tr.GetObject(fromdb.BlockTableId, OpenMode.ForRead);
if (fromBt.Has(blockName))
{
ObjectId blockId = fromBt[blockName];
ObjectIdCollection oic = new ObjectIdCollection();
oic.Add(blockId);
BlockTable bt=(BlockTable) tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
db.WblockCloneObjects(oic, bt.ObjectId, new IdMapping(), DuplicateRecordCloning.Replace,false);
tr.Commit();
}
tr.Dispose();
fromdb.Dispose();
} |
|