- UID
- 5280
- 积分
- 9466
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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.
![](source/plugin/imc_colorcode/images/loading.gif) - void ASDKtestfilter()
- {
- AcDbLayerTable *pLayerTbl ;
- acdbHostApplicationServices()->workingDatabase()->getLayerTable (pLayerTbl, AcDb::kForRead);
- AcDbObjectId extDictId = pLayerTbl->extensionDictionary();
- if (AcDbObjectId::kNull == extDictId)
- {
- acutPrintf("creating layerTable extension dictionary\n");
- if (Acad::eOk != pLayerTbl->upgradeOpen())
- {
- pLayerTbl->close();
- acutPrintf("unable to upgradeOpen Layer table\n");
- return;
- }
- pLayerTbl->createExtensionDictionary();
- extDictId = pLayerTbl->extensionDictionary();
- if (AcDbObjectId::kNull == extDictId)
- {
- pLayerTbl->close();
- acutPrintf("unable to create Layer's Ext Dictionary\n");
- return;
- }
- }
- pLayerTbl->close();
- AcDbDictionary *pExtDict;
- Acad::ErrorStatus es;
- es = acdbOpenObject(pExtDict, extDictId, AcDb::kForRead);
- if (es != Acad::eOk)
- {
- delete pExtDict;
- acutPrintf("unable to open Layer's Ext Dictionary\n");
- return;
- }
- // get or create the ACAD_LAYERFILTERS dictionary
- AcDbDictionary *pLayerFiltersDict = NULL;
- if (Acad::eOk != pExtDict->getAt( "ACAD_LAYERFILTERS", (AcDbObject*&)pLayerFiltersDict, AcDb::kForWrite ))
- {
- acutPrintf("creating ACAD_LAYERFILTERS dictionary\n");
- pExtDict->upgradeOpen();
- pLayerFiltersDict = new AcDbDictionary;
- AcDbObjectId new_id;
- if (Acad::eOk != pExtDict->setAt( "ACAD_LAYERFILTERS", pLayerFiltersDict, new_id ))
- {
- acutPrintf("unable to create ACAD_LAYERFILTERS dictionary\n");
- pExtDict->close();
- delete pLayerFiltersDict;
- return;
- }
- }
- pExtDict->close();
- AcDbObjectId Objid;
- AcDbXrecord *pXrec= new AcDbXrecord;
- resbuf *pHead;
- pHead=acutBuildList(1, "testFilter", 1, "*", 1, "*", 1, "*", 70, 13, 1, "*",
- 1, "*", RTNONE);
- pXrec->setFromRbChain(*pHead, NULL);
- pLayerFiltersDict->setAt("testFilter", pXrec, Objid);
- pLayerFiltersDict->close();
- pXrec->close();
- acutRelRb(pHead);
- }
|
|