CAA获取装配体下的零件
int DealWithProduct(char * InputPath){
CATDocument *pDoc = 0;
HRESULT rc = CATDocumentServices::OpenDocument(InputPath, pDoc) ;
if ( SUCCEEDED(rc) && ( NULL !=pDoc) )
{
cout <<" The document " << InputPath << " is opened" << endl ;
}else
{
cout <<" Pb in opening the " << InputPath <<" document" << endl;
return 1 ;
}
CATIDocRoots *piDocRootsDoc=NULL;
rc=pDoc->QueryInterface(IID_CATIDocRoots,(void**)&piDocRootsDoc);
CATIProduct_var RootProduct=NULL_var;
if (SUCCEEDED(rc))
{
CATListValCATBaseUnknown_var *pRootProducts=piDocRootsDoc->GiveDocRoots();
if (pRootProducts!=NULL)
{
if (pRootProducts->Size()>0)
{
RootProduct=(*pRootProducts)[1];
}
delete pRootProducts;
pRootProducts=NULL;
}
piDocRootsDoc->Release();
piDocRootsDoc=NULL;
}
CATIParmPublisher_var spParmPub(RootProduct);
CATListValCATISpecObject_var ListProduct;
spParmPub->GetDirectChildren("CATIProduct",ListProduct);
for (int i=1;i<=ListProduct.Size();i++)
{
cout<<ListProduct[i]->GetName()<<endl;
}
return -1;
}