C/C++教程

CAA获取Container——获取其他工厂

本文主要是介绍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;

 

这篇关于CAA获取Container——获取其他工厂的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!