24小时热门版块排行榜    

查看: 3132  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 帮忙看看fileCode +5 wwncly 2026-08-10 9/450 2026-08-11 08:10 by li9527
[基金申请] 小木虫上这么多卖论文的,真有人买论文么?感觉没必要啊 +4 Tide man 2026-08-10 4/200 2026-08-11 07:45 by emeraldine
[基金申请] 基金中了 +15 laoda193707 2026-08-06 15/750 2026-08-11 00:11 by jiafei2190
[基金申请] 综述论文作为代表作会不会影响评审专家的印象分? +10 yufeiwaner 2026-08-09 11/550 2026-08-10 18:47 by yufeiwaner
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +8 家与远方 2026-08-10 11/550 2026-08-10 17:09 by 六两废铜
[基金申请] 关于Filecode分析方法 +3 majunge000 2026-08-10 3/150 2026-08-10 15:46 by lch2012
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 奇怪,两个人的filecode固定段从头到尾一模一样 +4 布布和一二 2026-08-10 4/200 2026-08-10 14:50 by 医学老男孩
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +11 archvillain 2026-08-04 13/650 2026-08-10 14:41 by seekfind
[基金申请] 据悉今年马上要出结果了 +7 瞬息宇宙 2026-08-10 8/400 2026-08-10 12:42 by Vivilian
[基金申请] 面上项目filecode邪修 +5 西山十月 2026-08-09 7/350 2026-08-10 07:32 by 仁砚薪传
[基金申请] fileCode有新解读? +10 Tide man 2026-08-08 18/900 2026-08-09 12:55 by 仁砚薪传
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
[基金申请] 听说今天filecode变了 +24 布布和一二 2026-08-06 47/2350 2026-08-07 16:02 by zhiyanjiang
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 7/350 2026-08-07 13:11 by 医学老男孩
[基金申请] filecode +14 等待解的谜 2026-08-06 19/950 2026-08-07 12:20 by wlwhappy
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[基金申请] 有没有H口的?有收到消息的吗? +3 超级海虾 2026-08-04 3/150 2026-08-04 17:26 by 学教育滴
[基金申请] 纯娱乐,不喜欢勿喷 +7 Tide man 2026-08-04 10/500 2026-08-04 15:10 by loufangrui
信息提示
请填处理意见