I want to get a .NET Element from a COM Element...
using BCOM = Bentley.Interop.MicroStationDGN;
Element GetElementFromComElement (BCOM.Element oElement, bool addToModel)
BCOM.Application app = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp;
IntPtr pointer = (IntPtr)oElement.MdlElementRef();
Element el = Element.GetFromElementRef(pointer);
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.
Jon Summers said:The question: 'Can we obtain a .NET Element from COM?' remains unanswered.
It certainly can but needs a lots of tricks. I am asking my team member to write a such blog. Waiting for days.
Yongan.Fu said: I am asking my team member to write a such blog.
It would be great, thanks!
On the other hand, to add "load a cell from library" and "place a cell from library" functionality to NET API would be even much better, because my feeling is that 99% of all questions "COM/Interop vs new NET API" is about impossibility to work and place cells in libraries.
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point