How to Create addins using .net(C#)?

Dear all,

                    I am using Microstation v8i(SS3) with Visual Studio 2010. I have interest to develop addins using visual studio and i tried to create a addins with simple function (EX. Line create) its working fine but i need reference book of c# coding (like MicroStationVBA.chm) for create complex functions any one give me the reference.

Thanks & Regards,

Karthik M

  • Hi Karthik,

    Unknown said:
    but i need reference book of c# coding

    API used by managed code in V8i is the same (I guess from about 95%) as VBA, because it's based on the same Interop. So no extra documentation is required for the most of functionality and VBA works as NET documentation also. There is some functionality available in addins only (WinForms integration, access to more events etc.), but as far as I know there is no documentation for it available.

    Unknown said:
    for create complex functions

    What is "complex functions"? To be honest, it tells nothing :-( For somebody the complex functions can be the simple placement functions because he is beginner, for somebody more experienced it can be using multithreading code in addin or creating a generic library.

    Unknown said:
    give me the reference.

    The best approach in my opinion is to combine self-study of examples delivered with MicroStation SDK (three examples in dotnet folder) and existing discussions in programming forum(s).

    With regards,

     Jan

  • Hi jan,

              Thanks for you reply.

           API used by managed code in V8i is the same (I guess from about 95%) as VBA.

    In VBA If i get the line length from linestring using following Code.

          

    Private Function GetLength(ele As LineElement) As Double
    Dim length As Double
    length = ele.AsLineElement.length
    GetLengt = length
    End Function

    In C# i cant get the length(its not show the line length property) ,any namespace need to be add in visual studio.



  • Hi Karthik,

    Unknown said:
    any namespace need to be add in visual studio.

    Everything you need is available already in your computer: Use delivered examples and use Visual Studio tools.

    If you open delivered examples, e.g. TextMod, in Visual Studio (and make necessary changes in assembly locations etc.) you can see:

    ... so it's clear what assemblies should be referenced and what namespaces used. I guess these assemblies are necessary minimum, they can be more referenced to access some extra functionality.

    And in my opinion it's easy to use Object Browser in Visual Studio to locate in what assembly and in what namespace a particular class (like LineElement) resides.

    With regards,

      Jan

  • Hi Karthik,

    Jan already described exactly your needs of namespaces to create Addins.

    So I just want to add this small code example related to your question about length of lines.
    This example just demonstrates an approach how to place a line and returns the length of the line:

    // used namespaces:
    using System.Windows.Forms;
    using BCOM = Bentley.Interop.MicroStationDGN;
    using BMI = Bentley.MicroStation.InteropServices;
    
    
    //...
                BCOM.Application MSApp = BMI.Utilities.ComApp;
                BCOM.Point3d pStart = MSApp.Point3dFromXYZ(10,20,30);
                BCOM.Point3d pEnd = MSApp.Point3dFromXYZ(110,120,130);
                BCOM.LineElement oLine=  MSApp.CreateLineElement2(null, pStart, pEnd);
                MSApp.ActiveModelReference.AddElement (oLine);
                double dLength = oLine.Length;
                MessageBox.Show("Length of created line is: " + dLength.ToString());
    //...
    
    
    Best regards,
    Artur

  • Hi Jan & Artur,
    Thank you for your response it is useful for me. (Actually i am fresher for create addins that's why i am struggling now i understand thank you).

    Regards,
    Karthik M
  • I have wrote a series of articles to help you learning C# programming under MicroStation V8i as below:

    Learning MicroStation Addins Step by Step

    HTH, YongAn