| 查看: 3058 | 回复: 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。 请问我这种方法对不对,以及,如果方法是对的,那么为什么这里的接口会成空的? |
» 猜你喜欢
招收硕,博士,博士后及联培:设备状态监测, 可靠性与维护,人工智能,图像处理
已经有0人回复
实验室通风柜实验台哪个牌子好?哪个厂家品质好、质量好、售后好
已经有0人回复
金属材料论文润色/翻译怎么收费?
已经有165人回复
仅有一篇一作相关文章,其余的都是通讯,好申请面上么?
已经有6人回复
water research重复率要求
已经有3人回复
粉末热压生坯代加工
已经有0人回复
已编辑
已经有4人回复
车铣复合机床哪家品质好、质量好、性能好?
已经有0人回复
工程热物理方向-考博-自荐
已经有0人回复













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