几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   Earl,how to convert pFace(SldWorks::IFace2Ptr) to dFace(LPDISPATCH & OLE)? (http://www.dimcax.com/hust/showthread.php?t=735)

yogy 2007-05-20 09:49 AM

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

yogy 2007-05-20 09:49 AM

回复: 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.