24小时热门版块排行榜    

查看: 3080  |  回复: 0

kidsfes

新虫 (初入文坛)

[求助] 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。
请问我这种方法对不对,以及,如果方法是对的,那么为什么这里的接口会成空的?
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 kidsfes 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 299求调剂 +5 某某某某位 2026-03-21 5/250 2026-03-23 23:36 by 热情沙漠
[考研] 384求调剂 +3 子系博 2026-03-22 6/300 2026-03-23 21:45 by 子系博
[考研] 265求调剂 +10 梁梁校校 2026-03-17 10/500 2026-03-23 21:17 by 一切OK
[论文投稿] 急发核心期刊论文 +3 贤达问津 2026-03-23 5/250 2026-03-23 17:13 by 妹子不好惹
[考研] 0854电子信息求调剂 324 +3 Promise-jyl 2026-03-23 3/150 2026-03-23 13:43 by wangkm
[考研] 333求调剂 +6 87639 2026-03-21 10/500 2026-03-23 10:41 by Iveryant
[考研] 352求调剂 +3 大米饭! 2026-03-22 3/150 2026-03-22 23:28 by king123!
[考研] 319求调剂 +4 小力气珂珂 2026-03-20 4/200 2026-03-22 15:53 by ColorlessPI
[考研] 285求调剂 +6 ytter 2026-03-22 6/300 2026-03-22 12:09 by 星空星月
[考研] 材料与化工(0856)304求B区调剂 +3 邱gl 2026-03-20 7/350 2026-03-21 19:05 by 15709483992
[考研] 材料 271求调剂 +5 展信悦_ 2026-03-21 5/250 2026-03-21 17:29 by 学员8dgXkO
[考研] 299求调剂 +5 shxchem 2026-03-20 7/350 2026-03-21 17:09 by ColorlessPI
[考研] 266求调剂 +3 哇呼哼呼哼 2026-03-20 3/150 2026-03-21 16:46 by barlinike
[考研] 求调剂 +3 白QF 2026-03-21 3/150 2026-03-21 13:12 by zhukairuo
[考研] 一志愿华南师大 070300(化学)304分求调剂 +3 0703武芊慧雪304 2026-03-18 3/150 2026-03-21 00:48 by JourneyLucky
[考研] 321求调剂 +9 何润采123 2026-03-18 11/550 2026-03-20 23:19 by JourneyLucky
[考博] 申博26年 +3 八6八68 2026-03-19 3/150 2026-03-19 19:43 by nxgogo
[考研] 288求调剂,一志愿华南理工大学071005 +5 ioodiiij 2026-03-17 5/250 2026-03-19 18:22 by zcl123
[考研] 0703化学调剂 +5 pupcoco 2026-03-17 8/400 2026-03-19 13:58 by houyaoxu
[考研] 材料考研调剂 +3 xwt。 2026-03-19 3/150 2026-03-19 11:22 by w沐阳w
信息提示
请填处理意见