| 查看: 3073 | 回复: 0 | ||
[求助]
CATIA二次开发,零件环境下关于面选择以及颜色改变的问题
|
|
CATDocument * pDocument = NULL ; CATIPrtContainer_var spPartContainer = NULL_var; CATFrmEditor * pEditor =CATFrmEditor::GetCurrentEditor(); if (pEditor!=NULL) { CATPathElement spPath = pEditor->GetUIActiveObject(); CATBaseUnknown* spRef = spPath.CurrentElement( ); if (spRef) { CATILinkableObject *piLinkableObject = NULL; HRESULT rc = spRef->QueryInterface(IID_CATILinkableObject,(void**)& piLinkableObject); if ( SUCCEEDED(rc) ) { pDocument = piLinkableObject->GetDocument(); piLinkableObject->Release(); piLinkableObject = NULL ; if ( NULL != pDocument ) { CATInit_var spInit = pDocument; spPartContainer = (CATIPrtContainer*) spInit -> GetRootContainer("CATIPrtContainer" ;} } } } CATPathElement * pPathSelected = _pSelectionPlane1-> GetValue (); CATFrmEditor * pEdt = GetEditor(); CATHSO * pHSO = pEdt -> GetHSO(); if ( pHSO ) { pHSO -> Empty();//清除以前已高亮的 pHSO -> AddElements (pPathSelected); } CATUnicodeString luoshuangpingmian="未选择"; _dlg->_SelectorList006->GetLine(luoshuangpingmian,0); if (_dlg->_SelectorList006->IsSelect(0)) { CATUnicodeString Plane; Plane.BuildFromNum(PlaneNum); _dlg->_SelectorList006->SetLine(("平面."+Plane),0,CATDlgDataModify); PlaneNum++; _dlg->_SelectorList007->SetLine(("未选择" ,0,CATDlgDataModify);_dlg->_Editor012->ClearLine(); CATPlane_var AssPlane=pPathSelected->FindElement(IID_CATPlane); CATCell_var piFace; HRESULT rc; HRESULT rc1; rc=AssPlane -> QueryInterface(IID_CATCell,(void**) &piFace); CATIPrtPart_var spPrtPart=spPartContainer->GetPart(); CATIPartRequest_var spPartRequest = spPrtPart ; rc = spPrtPart->QueryInterface(IID_CATIPartRequest,(void**)&spPartRequest) ; CATLISTV(CATBaseUnknown_var) spMainPartBody; spPartRequest->GetSolidBodies("",spMainPartBody); for (int j=1;j<=spMainPartBody.Size();j++) { CATIBodyRequest_var spMainPartBodyBodyRequest=spMainPartBody[j]; CATLISTV(CATBaseUnknown_var) ListResult; spMainPartBodyBodyRequest->GetResults("",ListResult); CATIGeometricalElement_var spFeatureResultGeomElem=ListResult[1]; CATBody_var spPartTopoBody = spFeatureResultGeomElem->GetBodyResult(); CATIGeometricalElement *pGeomEltOnCurFeat1 = NULL; rc=spPartRequest->QueryInterface(IID_CATIGeometricalElement,(void**)&pGeomEltOnCurFeat1); if (rc) { CATIGeometricalElement_var pGeomEltOnCurFeat=pGeomEltOnCurFeat1; CATIBRepAccess_var spBRepAccess =CATBRepDecode(piFace, pGeomEltOnCurFeat) ; CATIVisProperties_var pIPropertiesOnSurface2=spBRepAccess; CATVisPropertiesValues MyPropertyOnSurface2 ; CATVisPropertyType PropTypeOnSurface2 = CATVPAllPropertyType; CATVisGeomType GeomTypeOnSurface2 =CATVPMesh ; rc1 = pIPropertiesOnSurface2->GetPropertiesAtt(MyPropertyOnSurface2,PropTypeOnSurface2, GeomTypeOnSurface2); if (rc1) { unsigned int r1,g1,b1; MyPropertyOnSurface2.GetColor(r1,g1,b1); cout<<r1<<" "<<g1<<" "<<b1<<endl; MyPropertyOnSurface2.SetColor(0,255,0); rc =pIPropertiesOnSurface2->SetPropertiesAtt(MyPropertyOnSurface2,CATVPColor,CATVPMesh); } } } } _SelectorList006是我的一个SelectorList的控件名称,我希望点选SelectorList后再点选零件的一个面,那个面能够改变颜色。但是运行调试的时候,总是显示斜体的那一行(rc1 = pIPropertiesOnSurface2->GetPropertiesAtt(MyPropertyOnSurface2,PropTypeOnSurface2, GeomTypeOnSurface2);),handler is null。 请问我这种方法对不对,以及,如果方法是对的,那么为什么这里的接口会成空的? |
» 猜你喜欢
招收26年秋季入学博士生(北科大高精尖学院 力学超材料/机器学习/增材制造相关方向)
已经有18人回复
读博入学申请
已经有1人回复
工程热物理与能源利用论文润色/翻译怎么收费?
已经有73人回复
金属求博导
已经有7人回复
2026 博士自荐-机器人机构学方向
已经有13人回复
提高合金高温性能
已经有1人回复
Advances in mechanical engineering 期刊如何提交署名的出版协议
已经有0人回复
西南交通大学国家级人才团队2026年博士研究生招生(考核制)—机械、材料、力学方向
已经有3人回复
北京理工大学(珠海)诚邀全球英才依托申报2026年优青(海外)项目!
已经有0人回复
英国国王大学院士团队诚招两名材料方面的博士后
已经有0人回复













;
回复此楼
点击这里搜索更多相关资源