Dear all
i want to access every body in the opened part, there is an example in SolieWorks API for it and i was carrying on based on it. But a problem for me, after using pPartDoc->GetBodies2(swAllBodies, FALSE, &vBodies) to get the bodies data which is vBodies and in variant. i cannot read every body information from it. based on the example in API, i did almost in the same way:
pPartDoc->GetBodies2(swAllBodies, FALSE, &vBodies); SAFEARRAY* psaBody = V_ARRAY(&vBodies); LPDISPATCH* pBodyDispArray = NULL; long nBodyHighIndex = -1; long nBodyCount = -1;
hr = SafeArrayAccessData(psaBody, (void **) &pBodyDispArray); ASSERT(S_OK == hr); ASSERT(NULL != pBodyDispArray); hr = SafeArrayGetUBound(psaBody, 1, &nBodyHighIndex); ASSERT(S_OK == hr); nBodyCount = nBodyHighIndex + 1; for (i = 0; i < nBodyCount; i++) { LPBODY2 pSWBody; pSWBody = pBodyDispArray[i]; ASSERT(pSWBody); hr = pSWBody->Select(VARIANT_TRUE, 0, &bRet); ASSERT(bRet); pSWBody->Release(); } hr = SafeArrayUnaccessData(psaBody); hr = SafeArrayDestroy(psaBody);
there is error duding compiling, it is said it is wrong to do pSWBody = pBodyDispArray[i]; because error C2440: '=' : cannot convert from 'struct IDispatch *' to 'struct IBody2 *' i am really confused, and cannot find a way to read each item in safearray and evaluate it to other object.
thanks for anyhelp you provide....
cheers SY