How do I get an instance of the interop Application class from the add-in? This is for Microstation Connect (Update 16), I want to be able to access the interop api from within the add-in for some code reusability purpose (since i have a decent amount from a few desktop apps that use the COM Api) and was looking to do some benchmarking and comparing of the interop vs the .net API performance for doing basic scanning/processing/updating elements.
With that, I understand i shouldn't be using GetObject as that will give me out-of-process instance of the Application, but is there a .NET or other api that will give me access to the interop Application? Something like Session.Istance.GetActiveDgnFile, but for the interop API?
Thanks.
HI Viktor,
Viktor_Kulik said:With that, I understand i shouldn't be using GetObject as that will give me out-of-process instance of the Application,
Exactly
Viktor_Kulik said:but is there a .NET or other api that will give me access to the interop Application?
Utilities.ComApp.<whatever>
Viktor_Kulik said:and was looking to do some benchmarking and comparing of the interop vs the .net API performance for doing basic scanning/processing/updating elements.
I have several comments to this topic:
Viktor_Kulik said:comparing of the interop vs the .net API
I think the rule here is not performance, but existing vs new code and APIs incompatibility:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Jan Šlegr said:especially Interop Element is not NET Element
Correct. But we have an article(sorry it is in Chinese) to describe how to convert between these two kinds of elements as below:
新老Element的相互转换
Certainly it is somewhat complicated.
Hi Jongan, any examples to convert an element in a reference?
Regards,
Mark
OpenRoads Designer 2023 | Microstation 2023.2 | ProjectWise 2023
Hi Mark,
Mark Shamoun said:any examples to convert an element in a reference?
I did not test the code with referenced elements, but it looks to me like general solution, so there should be no problem with references.
Is you question general or you experienced any problem?
I am having issues with Items.Find when the element is in a reference and has been converted from a NET element to an interop element. I was initially convinced some element data was not getting converted but it is looking like an Item Type issue. I will start another thread if i dont get to the bottom of it.
I agree it's probably too far from the original discussion that to start a new one makes sense, but anyway,,, ;-)
Mark Shamoun said: when the element is in a reference and has been converted from a NET element to an interop element.
Why to do anything like this? The conversion between Interop and NET is quite rare requirement, and is typically done when Interop functionality is missing in NET (e.g. like still no way how to place cell from cell library in NET).
Mark Shamoun said:I am having issues with Items.Find
EC API in NET is far more powerful (in fact, it is one from the best part of NET API, because EC was designed using some ideas from NET and EC was implemented at first in NET). So why to convert the element to use limited Item API with them in Interop?
Mark Shamoun said:but it is looking like an Item Type issue.
I do not think so. The whole conversation is about to convert "a handle to element in memory", but nothing else. And EC data (items) are "the else", because they are not stored with element, but in parallel, when there is a link between element and EC data.
So I guess the element is "transformed" between NET and Interop right, but EC data are not loaded, because they are covered by the conversion.