Hi,
with the function
Element.GetFromElementRef
I get a
Bentley.DgnPlatformNET.Elements.Element object
then I need to read the XData of the object. Till now i used
element.GetXData1(AppName);
but this functions need a
Bentley.Interop.MicroStationDGN.Element
So my question is, how to come from one the the other? And why there are two differnet Element classes without an esy way to convert.
E.g. a contructor that uses the other class
Greetings
Markus
Hi Markus,
Markus Hannweber said:And why there are two differnet Element classes...
You should be aware that in MicroStation CONNECT Edition, when working with managed API, there are two completely separate sets of API: old one and new one.
Markus Hannweber said:...without an esy way to convert.
Because these APIs use different memory. I remember "how to jump from one to another" was discussed several times in the past and I think there is no answer other than save to element to model, remember its ID and to read it using this ID from the second API.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi, thanks for the very fast answer.
So I undertand it better. but still I din't find a way, to don't come from one object to the other.
Is threre anywhere source code to how it should be done?
Markus Hannweber
Markus Hannweber said:but still I din't find a way, to don't come from one object to the other. Is threre anywhere source code to how it should be done?
I thought I wrote it in my previous post: there is no answer other than save to element to model, remember its ID and to read it using this ID from the second API
These two API are pines and apples, so when you want to use a method from Interop assembly like Element.GetXData(), you have to read an element using method also from Interop assemlby (e.g. ActiveModelReference.GetElementByID).
When you don't work with elements, you can combine both API versions freely. I can imagine e.g. to create primitive command using new API (inherited from DgnPrimitiveTool) but to use other functions from old Interop API.
thanks for info. So I will see how to do it
Hi Jan,
Jan Šlegr said:to create primitive command using new API (inherited from DgnPrimitiveTool)
I try to get this DgnPrimitiveTool in Addin APIs, but failed (get only IPrimitiveCommandEvents). Could you please enlighten me where I can find it.
Regards,
Frank
Hi Frenk,
unfortunately these classes are not described (yet) in NET documentation, but you can use C++ MicroStationAPI help.
Existing MicroStation NET examples (checked in Update 7 SDK) use these classes. You can use C:\Program Files\Bentley\MicroStationCONNECTSDK\examples\Elements\ManagedToolsExample\ code for example.
Thanks a lot Jan,
I found the example of DgnPrimitiveTool as well as DgnElementSetTool in the SDK\examples\ManagedToolsExample. Expecting the documentations to follow up.
Frank Zeng said:Expecting the documentations to follow up.
We all do :-) ... I guess SDK Update 8 will be released soon, so we will see whether this part of API will be documented or not.
One more note: You can follow up immediately, because these classes are described in MicroStationAPI C++ documentation. Even though nati ve and managed APIs are not always the same, in this case both APIs use the same approach (not quite sure whether it's for 100% 1:1, but enough to use C++ doc to learn how NET API works).
Hi, thanks for the hint. I will have a look