Reply
Solved! Go to solution

Error when accessing Profile property: E_NOINTERFACE

I get an error when accessing ExtrudedProtrusion.Profile

It get the same error for other Features and for GetProfile(..).

Other properties for the same object work ok.

 

If this were a bug in the SDK, I expect others would have already reported it, so I can only hope someone will tell me what I'm doing wrong.

 

Mini-project is attached and code follows:

 

using SolidEdgeAssembly;
using SolidEdgeFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ProblemCallingGetProfile
    {
    class Program
        {
        [STAThread]
        static void Main(string[] args)
            {
            try
                {
                OleMessageFilter.Register();

                SolidEdgeFramework.Application application =
                    (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

                TryProfile(application);
                }
            catch (System.Exception ex)
                {
                Console.WriteLine(ex.Message);
                }
            finally
                {
                OleMessageFilter.Revoke();
                Console.ReadKey();
                }

            }

        static void TryProfile(SolidEdgeFramework.Application application)
            {
           Exception xx = new Exception("part1.par should be the solid edge active document");
            if (application.Windows.Count < 1)
                throw xx;

            SolidEdgePart.PartDocument sprt = application.ActiveDocument as SolidEdgePart.PartDocument;
            if ((null == sprt) || (sprt.Name.ToLower() != "part1.par"))
                throw xx;

            foreach (SolidEdgePart.ExtrudedProtrusion xtrprotr in sprt.Models.Item(1).ExtrudedProtrusions)
                {
                Console.WriteLine("{0}   {1}", xtrprotr.DisplayName, xtrprotr.Name); // shows that we have a valid connection to the right object
                object oo = xtrprotr.Profile; // <=== throws: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))
                }
            }

        }
    }
2 REPLIES
Solution
Solution
Accepted by topic author BobKirkwood
‎08-20-2016 12:53 PM

Re: Error when accessing Profile property: E_NOINTERFACE

Hello Bob,

you have used a part with a synchronous body. There are no Profiles in the "features". 

As in the user interface there is no profile to change the feature.

 

You can check the ModellingModeType of the Feature to see if is  ordered or synchronous.

 

Both types of ExtrudedProtrusions share the same Interface in the API. If modelling type is synchronous, severel sub Interfaces are not implemented and you get the exception. 

 

regards

JB
VS2015, SE ST10

Re: Error when accessing Profile property: E_NOINTERFACE

That answers the question.

To see if I have this right:

  • With ST9 it is now possible to link TO a synchronous edited solid (or dumb solid)
  • ..but linking must still be from an ordered solid

That makes sense really since sync-edit solids should not be expected to keep trak of how they were edited.