iCAx开思工具箱
标题:
如何使用CATIMechanicalRootFactory创建特征!
[打印本页]
作者:
fgch3632585
时间:
2010-3-16 14:47
标题:
如何使用CATIMechanicalRootFactory创建特征!
HRESULT rc;
CATFrmEditor * pEditor = GetEditor();
if (NULL == pEditor)
{
return;
}
CATDocument *pDoc = pEditor->GetDocument();
if (NULL == pDoc)
{
return;
}
CATInit *spInitOnDoc = NULL;
rc = pDoc -> QueryInterface (IID_CATInit, (void**) &spInitOnDoc);
if (E_NOINTERFACE == rc)
{
Notify("NoCATInit");
return;
}
CATIPrtContainer *pIPrtCont = NULL ;
pIPrtCont = (CATIPrtContainer*)
spInitOnDoc->GetRootContainer("CATIPrtContainer");
if (NULL == pIPrtCont )
{
return;
}
CATISpecObject_var spSpecObjectOnPart = pIPrtCont->GetPart();
if (NULL_var == spSpecObjectOnPart)
{
return;
}
CATIMechanicalRootFactory
*pIMechanicalRootFactoryOnPart = NULL ;
rc = spSpecObjectOnPart->QueryInterface(IID_CATIMechanicalRootFactory,
(void**)&pIMechanicalRootFactoryOnPart);
if (SUCCEEDED(rc ))
{
Notify("SUCCEEDED");
}
else if (E_FAIL == rc )
{
Notify("E_FAIL == tc");
return;
}
else if(E_NOINTERFACE == rc )
{
Notify("E_NOINTERFACE == rc ");
return;
}
在创建一个新的MechanicalTool Feature或者是Geometrical Set时,要用到
CATIMechanicalRootFactory
接口,但按照上面的代码,总显示接口不存在!不知是什么原因,但可以通过CATIDesendants获得MechanicalPart下面的特征!
作者:
歆韵
时间:
2010-3-22 10:18
楼主可以尝试一下
CATIPrtContainer *pIPrtCont = NULL ;
pIPrtCont = (CATIPrtContainer*) spInitOnDoc->GetRootContainer("CATIPrtContainer");
if (NULL == pIPrtCont )
{
return;
}
CATIPrtPart_var spPrtPart( pIPrtCont->GetPart() );
再可以将它直接付给CATIMechanicalRootFactory
CATIMechanicalRootFactory_var spMechanicalRootFactoryOnPart = spPrtPart;
再用spMechanicalRootFactoryOnPart 来创建特征。我这样实现过,楼主可以试试
作者:
fgch3632585
时间:
2010-3-22 15:49
我程序里面的rc = spSpecObjectOnPart->QueryInterface(IID_CATIMechanicalRootFactory,
(void**)&pIMechanicalRootFactoryOnPart);
这段程序改为rc = pIPrtCont->QueryInterface(IID_CATIMechanicalRootFactory,
(void**)&pIMechanicalRootFactoryOnPart);
就可以了,还是谢谢你哈!
欢迎光临 iCAx开思工具箱 (https://t.icax.org/)
Powered by Discuz! X3.3