如何隐藏元素

本文原作者:Luca Gutierrez,经授权后转发

扫码关注微信公众号:CATIA二次开发助手

扫码关注微信公众号:CATIA二次开发助手

隐藏元素


使用CAA隐藏CATIA中的元素,首先需要通过QueryInterface函数得到对应元素的CATIVisProperties接口,然后调用CATIVisProperties接口的SetPropertiesAttr函数设置元素的显示属性。由于在实际开发工程中,经常用到隐藏或显示CATIA中的元素,所以可将其打包成公用函数方便调用。
  1. 1/** 
  2. 2* 隐藏元素 
  3. 3* @param ipListElemObj 
  4. 4* 元素列表 
  5. 5*/ 
  6. 6void HideElements(CATLISTV(CATISpecObject_var) ipListElemObj) 
  7. 7
  8. 8 for(int i=1;i<=ipListElemObj.Size();i++){ 
  9. 9 CATIVisProperties* pPropOnElem = NULL
  10. 10 HRESULT rc = ipListElemObj[i]->QueryInterface(IID_CATIVisProperties, 
  11. 11 (void**)&pPropOnElem); 
  12. 12 if(NULL != pPropOnElem){ 
  13. 13 CATVisPropertiesValues PropValue; 
  14. 14 CATVisPropertyType PropTypeOnPtObj = CATVPShow; 
  15. 15 CATVisGeomType GeomTypeOnPtObj = CATVPGlobalType; 
  16. 16 PropValue.SetShowAttr(CATNoShowAttr); 
  17. 17 rc = pPropOnElem->SetPropertiesAtt(PropValue, 
  18. 18 PropTypeOnPtObj, 
  19. 19 GeomTypeOnPtObj); 
  20. 20 pPropOnElem->Release(); 
  21. 21 pPropOnElem = NULL
  22. 22
  23. 23
  24. 24