iCAx开思工具箱
标题:
CATIA几何元素发布方法
[打印本页]
作者:
liuhuapin1981
时间:
2017-4-8 20:31
标题:
CATIA几何元素发布方法
近来在论坛上看到关于零件元素发布的几个贴,顺便截了几张图:
作者:
liuhuapin1981
时间:
2017-4-8 20:43
亲自验证了下,直接使用CATIPrdObjectPublisher接口函数
public virtual int
Publish
(
const
CATUnicodeString&
iName,
const
CATBaseUnknown*
iObject
= NULL )= 0
发布几何元素,的确会出现发布对象和几何元素关联失败,如截图所示。截图2有人提示需要建立发布对象的
CATIConnector,
没有提供具体过程
。
作者:
liuhuapin1981
时间:
2017-4-8 20:49
后来尝试使用V5Automation接口函数,结果也没成功!!!贴出代码,碰到类似问题的朋友请留言,大家一起交流交流:
if ( !! spPart )
{
CATIDescendants *pPartAsDescendant = 0;
if( SUCCEEDED(spPart->QueryInterface(IID_CATIDescendants, (void**)&pPartAsDescendant)) )
{
CATLISTV(CATISpecObject_var) Planes;
pPartAsDescendant->GetAllChildren("CATPlane", Planes);
if (Planes.Size())
{
CATBaseUnknown* geometryliu = NULL;
CATIConnector * pConnector = NULL;
rc =Planes[1]->QueryInterface(IID_CATBaseUnknown, (void**)&geometryliu) ;
//CATILinkableObject_var geometry = Planes[1];
CATILinkableObject_var geometry = Planes[1];
CATIAPart* pPartA = NULL;
rc = spPart->QueryInterface(IID_CATIAPart, (void**)&pPartA) ;
CATIAReference * iPointed;
const CATBSTR iLabel = ::SysAllocString( L"Part1/xy平面" );
pPartA->CreateReferenceFromName( iLabel, iPointed);
//CATBaseDispatch * iRef = NULL;
rc = Planes[1]->QueryInterface(IID_CATIAReference, (void**)&iPointed) ;
CATVariant * iVariant = NULL;
CATBSTR str = ::SysAllocString( L"发布平面" );
CComBSTR myCComBSTR(L"Part1/xy平面");
VARIANT varFromCCom;
varFromCCom.vt = VT_BSTR;
varFromCCom.bstrVal = myCComBSTR;
const CATVariant iIdentifier = varFromCCom;
CATIAProduct* pProductA = NULL;
CATIAPublications* pPublications = NULL;
CATIAPublication* pPubliction = NULL;
rc = spRootProduct->QueryInterface(IID_CATIAProduct, (void**)&pProductA) ;
if (SUCCEEDED(rc)&&pProductA!=NULL)
{
rc = pProductA->get_Publications(pPublications);
pProductA->Release();
pProductA = NULL;
if (SUCCEEDED(rc)&&pPublications!=NULL)
{
rc = pPublications->Add(str, pPubliction);
rc = pPublications->SetDirect( iIdentifier, iPointed);
}
}
pPartAsDescendant->Release();
pPartAsDescendant = NULL;
}
}
//获取发布接口
}
作者:
liuhuapin1981
时间:
2017-4-8 21:03
https://www.icax.org/thread-907222-1-1.html
作者:
liuhuapin1981
时间:
2017-4-11 10:32
经过三天的连续作战,问题终于得到解决。感兴趣有需要的可以到QQ群
608 148 242
留言。
欢迎光临 iCAx开思工具箱 (https://t.icax.org/)
Powered by Discuz! X3.3