2 Replies Latest reply on Aug 4, 2014 11:30 AM by Andrew Wilford

    Trying to select renamed Front Plane

    Andrew Wilford

      I am trying to select the Front Plane, which has been renamed in the part template file.

       

      I have enumerated the part features and found the three plane features. I have tried using GetSpecificFeature2 to convert the IFeature to an IRefPlane and doing a straight cast

       

      IRefPlane* refPlane = (IRefPlane*)feature;

       

      I then try to use IGetRefPlaneParams and get_Transform to get the plane normal to see if it is the Front Plane. The code keeps crashing and the examples don't help. There are so few useful C++ examples.

       

      Does anyone know how to achieve this in unmanaged C++?

        • Re: Trying to select renamed Front Plane
          Artem Taturevych

          You need to call ->QueryInterface (not direct cast) from the IDispatch returned from GetSpecificFeature2 to get the valid pointer to IRefPlane*.

          1 person found this helpful
          • Re: Trying to select renamed Front Plane
            Andrew Wilford

            Thank you, that worked. Here is a code snippet, in case anyone needs to do something similar:

             

              IDispatch* dispatch = NULL;

              IRefPlane* refPlane = NULL;

              feature->GetSpecificFeature2(&dispatch);

              HRESULT hr = dispatch->QueryInterface(__uuidof(IRefPlane), reinterpret_cast<void**>(&refPlane));

              if(refPlane != NULL) {

                  double *data = new double[16];

                  refPlane->IGetRefPlaneParams(data);

                  if(fabs(data[6]) < 1e-6 && fabs(data[7]) < 1e-6 && fabs(data[8] - 1.0) < 1e-6) {

                      ...

                  }

            }