Q:
Dear Earl,
It is OK when iterate all faces with COM stead of OLE. My next question is how to convert pFace (SldWorks::IFace2Ptr) to dFace (LPDISPATCH & OLE)?
PS: my consequent code still uses OLE.
My code as follows:
// LPDISPATCH dBody which from OLE
SldWorks::IBody2Ptr pBody = NULL;
SldWorks::IEnumFaces2Ptr pEnumFaces = NULL;
long nFetchedFaces = -1;
SldWorks::IFace2Ptr pFace = NULL;
// COM iterate stead of OLE
dBody->QueryInterface(__uuidof(SldWorks::IBody2), (LPVOID*)&pBody);
// iterate all faces of a body
HRESULT hres = pBody->EnumFaces ( &pEnumFaces );
if(S_FALSE == hres)
return false;
hres = pEnumFaces->Next(1, &pFace, &nFetchedFaces);
if(S_FALSE == hres)
return false;
while (nFetchedFaces > 0)
{
// reset current face and get the next face
pFace = NULL;
hres = pEnumFaces->Next(1, &pFace, &nFetchedFaces);
// OLE object stead of COM because my consequent code still uses OLE.
// LPDISPATCH dFace = NULL;
// pFace->QueryInterface(IID_IDispatch, (LPVOID*)&dFace);
// How to convert pFace (SldWorks::IFace2Ptr) to dFace (LPDISPATCH & OLE)?
}
// reset face enumerator
pEnumFaces = NULL;
pBody = NULL;
yogy |