I have a question about using IGetChildren in SolidWorks 2005 API in Visual C++ 6.0
Suppose I have an Assembly file containing 3 part files. I would like to use the IGetChildren function to get the name of each part (component) one by one, using the code below. But after IGetChildren is called, in the pChildren array, only the first element gets the first part. The remaining elements could retrieve nothing.
Would someone figure out why IGetChildren() cannot get all the children (parts) in this case? Many many thanks!
IComponent2** pChildren = NULL; CComQIPtr pModel; CComQIPtr pConfiguration; int nChildren, i; if (pModel->IGetActiveConfiguration(&pConfiguration) == S_OK ) { if ( pConfiguration->IGetRootComponent2(&pRootComponent) == S_OK ) {
HRESULT hres = pComponent->IGetChildrenCount(&nChildren); if ( S_OK == hres && nChildren > 0 ) { pChildren = new IComponent2* [nChildren]; hres = pComponent->IGetChildren(pChildren); if (S_OK == hres) { for ( i=0; i