| 查看: 3060 | 回复: 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。 请问我这种方法对不对,以及,如果方法是对的,那么为什么这里的接口会成空的? |
» 猜你喜欢
小论文投稿
已经有3人回复
2026英国女王大学机械学院电池储能CSC全奖博士招聘
已经有10人回复
机械工程论文润色/翻译怎么收费?
已经有61人回复
2026英国女王大学机械学院电池储能CSC全奖博士招聘
已经有1人回复
华南农业大学蒋恩臣教授、许细薇教授团队招聘生物质领域博士、硕士
已经有2人回复
紧急招博士生报考
已经有20人回复
第五届自动化、控制与通信工程国际研讨会(lWACCE 2026)
已经有0人回复
第九届机械、电子和工业工程国际会议(MEIE 2026)
已经有0人回复
第四届光通信和光学信息处理国际学术会议(OCOIP2026)
已经有0人回复
第五届光电信息与计算机工程国际学术会议(OICE2026)
已经有0人回复













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