如何高亮特征

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

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

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

高亮特征


高亮在CATIA应用还是比较广泛的,尤其是面对复杂的装配环境下,通过高亮显示去引导设计人员进行操作、通过高亮显示查看效果等。在实际使用过程中可打包成公有函数方便调用。
  1. 1/** 
  2. 2* 高亮特征 
  3. 3* @param spSpec 
  4. 4* 高亮特征 
  5. 5*/ 
  6. 6HRESULT HighLightSpecObject (CATISpecObject_var spSpec, CATBoolean boolClearHistory) 
  7. 7
  8. 8 HRESULT rc = E_FAIL; 
  9. 9 CATFrmEditor * pEditor = CATFrmEditor::GetCurrentEditor(); 
  10. 10 if(NULL == pEditor ) 
  11. 11 return rc; 
  12. 12 CATHSO * pHSO = pEditor->GetHSO(); 
  13. 13 if(NULL == pHSO ) 
  14. 14 return rc;  
  15. 15 if(boolClearHistory)//为1时,清楚所有已有的高亮 
  16. 16 pHSO->Empty(); 
  17. 17 CATPathElement pContext = pEditor->GetUIActiveObject(); 
  18. 18 CATIBuildPath * piBuildPath = NULL
  19. 19 rc =spSpec->QueryInterface(IID_CATIBuildPath, (void **)&piBuildPath); 
  20. 20 if(SUCCEEDED(rc) && piBuildPath != NULL
  21. 21
  22. 22 CATPathElement * pPathElement = NULL
  23. 23 rc = piBuildPath->ExtractPathElement(&pContext, &pPathElement); 
  24. 24 if (pPathElement != NULL
  25. 25
  26. 26 pHSO->AddElement(pPathElement); 
  27. 27 pPathElement->Release(); 
  28. 28 pPathElement = NULL
  29. 29
  30. 30 piBuildPath->Release(); 
  31. 31 piBuildPath = NULL
  32. 32
  33. 33 return S_OK; 
  34. 34