CAA获取Container——获取其他工厂
作者:互联网
HRESULT CreatePointCmd::GetCurrentPartInformation(CATIGSMFactory_var &ospGSMFactory)
//写一个获取当前部件信息的方法,函数输出了ospGSMFactory
{
HRESULT rc = E_FAIL;//声明一个RC
//用这个方法得到当前编辑器
//定义个pEditor来判断是否获得当前编译对象
//类:CATFrmEditor 方法:GetCurrentEditor
CATFrmEditor * pEditor = CATFrmEditor::GetCurrentEditor();
if (pEditor == NULL)
{
return E_FAIL;
}
//当pEditor获得到了编译器,定义一个pDoc来判断获得当前对象文档
//类:CATDocument 方法:GetDocument 接口:CATIContainerOfDocument
CATDocument *pDoc = pEditor ->GetDocument();
if (pDoc == NULL)
{
return E_FAIL;
}
CATIContainerOfDocument_var spConODocs = pDoc;
if (spConODocs == NULL_var)
{
return E_FAIL;
}
//获取特征容器
//类:CATIContainer 方法:GetSpecContainer
CATIContainer * pSpecContainer = NULL;
rc = spConODocs ->GetSpecContainer(pSpecContainer);
if (pSpecContainer == NULL || FAILED(rc))
{
return E_FAIL;
}
//获取曲面工厂
//类:
rc = pSpecContainer->QueryInterface(IID_CATIGSMFactory,(void**)&ospGSMFactory);
if (ospGSMFactory == NULL_var)
{
return E_FAIL;
}
return rc;
}
//更简便的写法
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
CATDocument *pDoc = pEditor->GetDocument();
CATIContainerOfDocument_var spConODocs = pDoc;
CATIContainer * _pContainer = NULL;
HRESULT rc = spConODocs ->GetSpecContainer(_pContainer);
CATIGSMFactory_var spGSMFactory = NULL_var;
spGSMFactory = _pContainer;
标签:FAIL,Container,return,获取,rc,var,pEditor,CAA,NULL 来源: https://www.cnblogs.com/Breadss/p/14840020.html