CATIProduct_var GetCurrentPrdInstance()
{ CATIProduct_var spPrdInstance=NULL_var;
//获得当前editor CATFrmEditor* editor = CATFrmEditor::GetCurrentEditor (); if (NULL == editor) return spPrdInstance; //获得当前文档 CATDocument* pCurDoc= editor-> GetDocument(); if (NULL == pCurDoc) return spPrdInstance; if(pCurDoc->IsAKindOf("CATProduct")==0) return spPrdInstance; CATPathElementpath=editor->GetUIActiveObject(); if(path.GetSize()==0) return spPrdInstance; CATIProduct* pPrdInstance=NULL; HRESULT rs=path.Search(IID_CATIProduct,(void**)&pPrdInstance); if (FAILED(rs) || pPrdInstance==NULL) return spPrdInstance; spPrdInstance=pPrdInstance; pPrdInstance->Release(); pPrdInstance=NULL; // return spPrdInstance; }
|