几何尺寸与公差论坛

 找回密码
 注册
查看: 2488|回复: 1

Earl,how to convert pFace(SldWorks::IFace2Ptr) to dFace(LPDISPATCH &

[复制链接]
发表于 2007-5-20 09:49:22 | 显示全部楼层 |阅读模式
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
 楼主| 发表于 2007-5-20 09:49:48 | 显示全部楼层

回复: Earl,how to convert pFace(SldWorks::IFace2Ptr) to dFace(LPDISPATCH &

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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 18:45 , Processed in 0.038665 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表