Solidworks api (IAddBodies)



Hi,

I am coding to implement to extract mass property from given part file
using C++
I want to add bodies using MassProperty.IAddBodies()
However, whenever nBodyCount is bigger than 1, IAddBodies function does
not work. in fact, program downs.
I have tried several things and to find related reference but I could
not.
Thus can you help me?
Code is following
...
hres = comp->GetBodies2(swSolidBody, &vBodyArr);
SAFEARRAY *pSafeArrBody = V_ARRAY(&vBodyArr);
LPDISPATCH *pDispArrBody = NULL;
long nBodyCount = -1;
long nBodyHighIndex = -1;
hres = SafeArrayAccessData(pSafeArrBody, (void **) &pDispArrBody);
(*pDispArrBody)->QueryInterface(__uuidof(IBody2),
reinterpret_cast<void**>(&pBodyArr));
hres = SafeArrayGetUBound(pSafeArrBody, 1, &nBodyHighIndex);
nBodyCount = nBodyHighIndex + 1;
(*massProperty)->IAddBodies(nBodyCount, &pb, &isAdded);
...

Thanks

--
Message posted using http://www.talkaboutcad.com/group/comp.cad.solidworks/
More information at http://www.talkaboutcad.com/faq.html

.