CAA二次开发对两个part进行Booler操作,运行错误,代码贴出,请大神帮忙解决
//获取CATBody
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
CATDocument *pDoc = pEditor->GetDocument();
CATIDocRoots* piDocRootsOnDoc = NULL;
HRESULT rc = pDoc->QueryInterface(IID_CATIDocRoots,
(void**) &piDocRootsOnDoc);
/////获得Product的Root,是第一个元素
CATListValCATBaseUnknown_var* pRootProducts = piDocRootsOnDoc->GiveDocRoots();
CATIProduct_var spRootProduct = NULL_var;
if (pRootProducts && pRootProducts->Size()) //如果pRootProduct不为空,获得第一个元素
{
spRootProduct = (*pRootProducts)[1];
delete pRootProducts;
pRootProducts = NULL;
}
piDocRootsOnDoc->Release();
piDocRootsOnDoc = NULL;
////// Get CATIProduct handle on the root product.
CATIProduct *piProductOnRoot = NULL;
rc = spRootProduct->QueryInterface(IID_CATIProduct,
(void**) &piProductOnRoot);
CATIProduct_var spRef = piProductOnRoot ->GetReferenceProduct();
CATBody_var ResultBody;
if ( NULL_var != spRef )
{
CATILinkableObject * piLinkableObject = NULL;
HRESULT rc = spRef->QueryInterface( IID_CATILinkableObject, (void**)& piLinkableObject );
if(SUCCEEDED(rc))
{
CATDocument * pDocument = NULL ;
pDocument = piLinkableObject->GetDocument();
CATIContainerOfDocument * pIContainerOfDocumentOnDoc = NULL;
rc = pDocument->QueryInterface(IID_CATIContainerOfDocument, (void**)&pIContainerOfDocumentOnDoc);
if(SUCCEEDED(rc))
{
CATIContainer * pContainer = NULL ;
rc = pIContainerOfDocumentOnDoc->GetSpecContainer(pContainer);
if(SUCCEEDED(rc))
{
CATIPrtContainer *pSpecContainer = NULL;
rc = pContainer->QueryInterface(IID_CATIPrtContainer, (void**)&pSpecContainer) ;
if(SUCCEEDED(rc))
{
CATIPrtPart_var spPart = pSpecContainer->GetPart();
pSpecContainer->Release();
pSpecContainer = NULL ;
CATIPartRequest *pPartAsRequest = 0;
rc = spPart->QueryInterface(IID_CATIPartRequest, (void**)&pPartAsRequest) ;
if(SUCCEEDED(rc))
{
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();
//CATCGMJournalList *pJournal = new CATCGMJournalList();
CATTopData topdata(pConfig);
CATGeoFactory* piGeomFactory = CATCreateCGMContainer() ;
CATDynBoolean* pOperatorBool = CATCreateDynBoolean(piGeomFactory,&topdata,CATBoolUnion,CATBodyVector.at(0),CATBodyVector.at(1));
if(pOperatorBool!=NULL)
{
pOperatorBool->Run();
MessageBox(NULL,_T("success2!"),_T("通知消息"),NULL);
CATBody* resultBody = pOperatorBool->GetResult();
if(resultBody==NULL)
{
MessageBox(NULL,_T("fail!"),_T("通知消息"),NULL);
}
}