[CONNECT .NET] Get In-Memory Element from COM Impossible

I want to get a .NET Element from a COM Element...

using Bentley.DgnPlatformNET;
using Bentley.DgnPlatformNET.Elements;
using Bentley.MstnPlatformNET;
using BCOM = Bentley.Interop.MicroStationDGN;
Element GetElementFromComElement (BCOM.Element oElement, bool addToModel)
  if (addToModel)
    BCOM.Application app = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp;
  IntPtr pointer = (IntPtr)oElement.MdlElementRef();
  Element el = Element.GetFromElementRef(pointer);
  return el;

If I call the above function with addToModel True, it works. If I call the function with addToModel False, it returns a null.  But I don't want to write the COM element to file: I want an in-memory .NET Element.  What's going on?

I've marked this thread as solved, because a work-around exists.  The question: 'Can we obtain a .NET Element from COM?' remains unanswered.

Parents Reply Children