![]() |
Earl,how to convert pFace(SldWorks::IFace2Ptr) to dFace(LPDISPATCH & OLE)?
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 |
回复: Earl,how to convert pFace(SldWorks::IFace2Ptr) to dFace(LPDISPATCH & OLE)?
R:
The SldWorks::IFace2 interface is derived from IDispatch. This means that you can use IFace2.AttachDispatch directly or simply use QueryInterface to get the IDispatch pointer from the object and use it in the IFace2 constructor. Regards, -Earl |
所有的时间均为北京时间。 现在的时间是 10:49 AM. |