找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1425|回复: 0

[图层] 用ARX增加 layer filter

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-17 03:18:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Add a layer filter using ARX - access the layer table extension dictionary


问题:

Layer filters are used to hide or display layers based on certain properties
in the Layer Properties Dialog. Is there an API that will programmatically add
a layer filter?

解答:

Layer filters are stored in the extension dictionary of the LayerTable. Below
is an example that creates a layer filter named testFilter.


  1. void ASDKtestfilter()
  2. {

  3. AcDbLayerTable *pLayerTbl ;
  4. acdbHostApplicationServices()->workingDatabase()->getLayerTable (pLayerTbl, AcDb::kForRead);

  5. AcDbObjectId extDictId = pLayerTbl->extensionDictionary();
  6. if (AcDbObjectId::kNull == extDictId)
  7. {
  8.         acutPrintf("creating layerTable extension dictionary\n");
  9.   if (Acad::eOk != pLayerTbl->upgradeOpen())
  10.         {
  11.             pLayerTbl->close();
  12.             acutPrintf("unable to upgradeOpen Layer table\n");
  13.             return;
  14.         }
  15.         pLayerTbl->createExtensionDictionary();
  16.         extDictId = pLayerTbl->extensionDictionary();
  17.         if (AcDbObjectId::kNull == extDictId)
  18.         {
  19.             pLayerTbl->close();
  20.             acutPrintf("unable to create Layer's Ext Dictionary\n");
  21.             return;
  22.         }
  23. }
  24. pLayerTbl->close();

  25. AcDbDictionary *pExtDict;

  26. Acad::ErrorStatus es;
  27. es = acdbOpenObject(pExtDict, extDictId, AcDb::kForRead);
  28. if (es != Acad::eOk)
  29. {
  30.   delete pExtDict;
  31.   acutPrintf("unable to open Layer's Ext Dictionary\n");
  32.         return;
  33. }

  34. // get or create the ACAD_LAYERFILTERS dictionary
  35. AcDbDictionary *pLayerFiltersDict = NULL;
  36. if (Acad::eOk != pExtDict->getAt( "ACAD_LAYERFILTERS", (AcDbObject*&)pLayerFiltersDict, AcDb::kForWrite ))
  37.     {
  38.         acutPrintf("creating ACAD_LAYERFILTERS dictionary\n");

  39.         pExtDict->upgradeOpen();
  40.   pLayerFiltersDict = new AcDbDictionary;

  41.   AcDbObjectId new_id;
  42.       if (Acad::eOk != pExtDict->setAt( "ACAD_LAYERFILTERS", pLayerFiltersDict, new_id ))
  43.         {
  44.             acutPrintf("unable to create ACAD_LAYERFILTERS dictionary\n");
  45.    pExtDict->close();
  46.    delete pLayerFiltersDict;
  47.             return;
  48.         }
  49. }
  50. pExtDict->close();

  51. AcDbObjectId Objid;
  52. AcDbXrecord *pXrec= new AcDbXrecord;
  53. resbuf *pHead;

  54. pHead=acutBuildList(1, "testFilter", 1, "*", 1, "*",  1, "*", 70, 13, 1, "*",
  55.        1, "*", RTNONE);

  56. pXrec->setFromRbChain(*pHead, NULL);
  57. pLayerFiltersDict->setAt("testFilter", pXrec, Objid);

  58. pLayerFiltersDict->close();
  59. pXrec->close();
  60. acutRelRb(pHead);
  61. }


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-21 17:40 , Processed in 0.257665 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表