0 Replies Latest reply on Oct 6, 2015 3:58 PM by Joel Foo

    How to assign an IDispatch* element

    Joel Foo

      I'm trying to select a Face of a Feature in a Part document. I've gotten the Feature I wanted, but I can't seem to assign the Faces I get to my IFace object! Pardon my code and obvious lack of experience, I've only just learnt C++.

       

      CComPtr<SldWorks::IFace2> swFace;
        VARIANT facearr = swFeat->GetFaces(); //GetFaceCount() is correct, at 3. 
        SAFEARRAY* psa = V_ARRAY(&facearr); //Variant to SafeArray
        LPDISPATCH swFacep;
        hr = SafeArrayAccessData(psa, (void **)&swFacep); //SafeArray to array of IDispatch pointers. 
      

       

      At this point, I've tried the methods laid out in the Solidworks API help, but have gotten nowhere. To add: I've also tried

       

      swFacep[i]->QueryInterface(IID_IFace2, &swFace)

       

      But IID_IFace2 is undefined.

       

      I'm not sure what I'm doing wrong or how to proceed. I would be grateful for any help!