[CONNECT C#] ElementHandle

I am starting to develop Addins in Microstatin Connect Edition Update6 with C#. I come across many ElementHandle description in the SDK, but still do not know how to create or retrive it. 

While trying to construct an ElementHandle, i was suggested with multiple definition as listed below, which one should I choose?

In the SDK, I also noticed the type ElementHandle* , can anybody tell me how to get this type's instance and its difference with ElementHandle?

  • Hi,

    I come across many ElementHandle description in the SDK, but still do not know how to create or retrive it.

    It depends on situation, so you should explain what you want to achieve (e.g. get a geometry of an existing element, to create new element) and also details whether you use primitive command or modification command etc.

    Unfortunately there is no an "introduction to handlers" or summary / overview for beginners available, so it's better to discuss one specific scenario than to try to describe everything.

    With regards,

      Jan

  • ElementHandle is a native (C++) class. The C# equivalent is DgnPlatformNET.Elements.Element. Numerous subclasses thereof exist (e.g., ConeElement, ArcElement, CellHeaderElement, etc).

    If that does not help, follow Jan's advice and be more specific about what you're trying to accomplish.

    Regards,

    Paul

  • I also noticed the type ElementHandle* , can anybody tell me how to get this type's instance and its difference with ElementHandle?

    * and -> are pointer operators in C++.  C# always uses a reference to allocated objects: it doesn't use pointers.  You don't see the * or -> operator in C#.

    C++ uses pointers extensively.  You will see the * and -> operators frequently.

     
    Regards, Jon Summers
    LA Solutions

  • Thanks Jan,

    After went over the SDK for more instances of ElementHandle, I found it's frequently used in the protected constructor for Element class and its hierachies, besides, methods/properties calling for ElementHandle/ElementHandle* have big chance to have alternate methods where ElementHandle can be replaced by a managed class instance.

    but knowing those can not full release my wonder for where the ElementHandle might be inevitably needed in Addins programming, given the not only one ElementHandle definition suggested in the VS IDE(as the picture shows above).

    I am a newcomer to he Microstation programming without any experiences of  C++, so I get confused every time with the ElementHandle (and the unmanaged code, pointer and other C++ features that can not be referenced) but do not know how to use it. Can you please present some cases where ElementHandle  is used in Addin programming or how it could be transformed into the managed applications.

    Best regards, 

    Frank