24小时热门版块排行榜    

查看: 3058  |  回复: 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 的主题更新
信息提示
请填处理意见