乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 90|回复: 0

[编程交流] WblockClon​eObjects memory not

[复制链接]

1

主题

1

帖子

0

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 22:03:46 | 显示全部楼层 |阅读模式
Hi,
i need to read an external dwg and import only some entities.
I use WblockCloneObjects, it work fine but i found a memory problem, the memory is not disposed autocad memory process significantly increases after every WblockCloneObjects.
 
Where is the problem?
 
Thank you very much.
  1. [CommandMethod("TestClone", CommandFlags.Transparent)]       public void TestClone()       {           // repeated 20 times to highlight the memory consumption           for (int i = 0; i < 20; i++)           {               ObjectIdCollection filteredIds = new ObjectIdCollection();               Database targetDb = ACAP.Application.DocumentManager.MdiActiveDocument​.Database;                              using (Transaction trMain = targetDb.TransactionManager.StartTransaction())               {                   using (Database db = new Database(false, true))                   {                       // read the source dwg                       db.ReadDwgFile(@"D:\he10t.dwg", FileOpenMode.OpenForReadAndAllShare, true, "");                                              // get all entities                       using (Transaction trSource = db.TransactionManager.StartTransaction())                       {                           BlockTable pBT = (BlockTable)trSource.GetObject(db.BlockTableId, OpenMode.ForRead, false);                           BlockTableRecord pBTR = (BlockTableRecord)trSource.GetObject(pBT[blockTabl​eRecord.ModelSpace], OpenMode.ForRead, false);                           foreach (ObjectId id in pBTR)                           {                               // ...open entity and filter                               filteredIds.Add(id);                           }                       }                       // clone the filtered entities in current document                       using (ACAP.DocumentLock dl = ACAP.Application.DocumentManager.MdiActiveDocument​.LockDocument())                       {                           using (IdMapping mapping = new IdMapping())                           {                               // now clone the objects into the destdb                               ObjectId destDbMsId = SymbolUtilityServices.GetBlockModelSpaceId(targetD​b);                               db.WblockCloneObjects(filteredIds, destDbMsId, mapping, DuplicateRecordCloning.Replace, false);                           }                       }                   }                   trMain.Commit();               }                   filteredIds.Dispose();           }                  }
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 09:05 , Processed in 0.646453 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表