iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1835|回复: 2
打印 上一主题 下一主题

[技术交流] CAA两个part布尔运算出错,该怎么解决,代码以贴出,请高手帮忙解决,谢谢

[复制链接]
跳转到指定楼层
楼主
发表于 2017-8-18 20:45:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
//获取CATBody       
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
CATDocument *pDoc = pEditor->GetDocument();
CATIDocRoots* piDocRootsOnDoc = NULL;
HRESULT rc = pDoc->QueryInterface(IID_CATIDocRoots,
                      (void**) &piDocRootsOnDoc);

CATListValCATBaseUnknown_var* pRootProducts = piDocRootsOnDoc->GiveDocRoots();
CATIProduct_var spRootProduct = NULL_var;
if (pRootProducts && pRootProducts->Size())
{  
spRootProduct = (*pRootProducts)[1];
}
CATIProduct *piProductOnRoot = NULL;
rc = spRootProduct->QueryInterface(IID_CATIProduct,
                               (void**) &piProductOnRoot);
        CATIProduct_var spRef = piProductOnRoot ->GetReferenceProduct();
CATBody_var ResultBody;
CATILinkableObject * piLinkableObject = NULL;
HRESULT rc = spRef->QueryInterface( IID_CATILinkableObject, (void**)& piLinkableObject );
CATDocument * pDocument = NULL ;
pDocument = piLinkableObject->GetDocument();
CATIContainerOfDocument * pIContainerOfDocumentOnDoc = NULL;
rc = pDocument->QueryInterface(IID_CATIContainerOfDocument, (void**)&pIContainerOfDocumentOnDoc);
CATIContainer * pContainer = NULL ;
rc = pIContainerOfDocumentOnDoc->GetResultContainer(pContainer);
CATIPrtContainer *pSpecContainer = NULL;
rc = pContainer->QueryInterface(IID_CATIPrtContainer, (void**)&pSpecContainer) ;
CATIPrtPart_var spPart = pSpecContainer->GetPart();
pSpecContainer->Release();
pSpecContainer = NULL ;
CATIPartRequest *pPartAsRequest = 0;
rc = spPart->QueryInterface(IID_CATIPartRequest, (void**)&pPartAsRequest) ;
CATLISTV(CATBaseUnknown_var) BodyList;
pPartAsRequest->GetSolidBodies(CATUnicodeString(" "), BodyList);
for(int curSetIdx=1; curSetIdx<=BodyList.Size(); curSetIdx++)
{
CATBaseUnknown_var CurrentSet = BodyList[curSetIdx] ;
CATIBodyRequest *pBodyRequestOnCurrentSet = NULL;
rc = CurrentSet->QueryInterface(IID_CATIBodyRequest, (void**)&pBodyRequestOnCurrentSet);CATLISTV(CATBaseUnknown_var) pListResult;
rc = pBodyRequestOnCurrentSet->GetResults(CATUnicodeString(" "), pListResult);

CATBaseUnknown_var CurrentFeat = pListResult[1] ;
CATIGeometricalElement *pGeomEltOnCurFeat = 0;
rc = CurrentFeat->QueryInterface(IID_CATIGeometricalElement, (void**)&pGeomEltOnCurFeat);
ResultBody = pGeomEltOnCurFeat->GetBodyResult();
}

//下面是进行布尔操作
CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
CATTopData topdata(pConfig);
CATGeoFactory* piGeomFactory = CATCreateCGMContainer() ;
CATDynBoolean* pOperatorBool = CATCreateDynBoolean(piGeomFactory,&topdata,CATBoolUnion,body1,body2);
if(pOperatorBool!=NULL)
{
pOperatorBool->Run();
CATBody* resultBody = pOperatorBool->GetResult();
if(resultBody==NULL)
{
MessageBox(NULL,_T("fail!"),_T("通知消息"),NULL);
}
}

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2017-8-20 09:40:51 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

点评

嗯,谢谢回复,这是一个问题,还有就是,布尔运算的两个Body必须在一个part下,另外问下,布尔运算后的结果怎样再挂载到Part下?  详情 回复 发表于 2017-8-22 09:47
板凳
 楼主| 发表于 2017-8-22 09:47:47 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-4-29 03:06 , Processed in 0.012889 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表