Call Microstation from a VB.net program

Good morning all

I know this is not strictly Microstation but here goes.  Having rebuilt my computer I now want to run a VB.net program that "draws" lines in Microstation.

 I have a line in NameSpace "imports microststionDGN" but I cannot remember how to make Microststion available. A quick reminder, Jon, please.

thanks

Patrick

  • Unknown said:
    I have a line in NameSpace "imports microststionDGN"

    First, get your spelling correct.  Although we humans know what you're writing about, VB.NET doesn't.  It wont be able to find microststionDGN.  Why not just copy the line from your VB.NET code and paste it here?

    When you use MicroStation from a .NET language, you are referencing (a.k.a. importing) the VBA COM server.

    Unknown said:
    I cannot remember how to make MicroStation available

    Which version of Viz Studio are you using?  There should be a Project Settings dialog with tabs, one of which lets you add references to .NET assemblies and another to COM servers.

    But, as you say, that's Viz Studio stuff rather than MicroStation stuff.

     
    Regards, Jon Summers
    LA Solutions

  • Thanks Jon

    spelling has improved now I have taken the boxing gloves off.  I'm using Visual Basic 2008 Express.

    Patrick

  • Unknown said:
    I'm using Visual Basic 2008 Express

    I'm unfamiliar with the Express editions of Viz Studio.  Unsurprisingly, they are short on features offered by the commercial versions.  As a result, you may receive answers based on those full versions that won't work with the Express version.

     
    Regards, Jon Summers
    LA Solutions

  • Patrick,

    From the title of your request it sounds like you are creating an external windows .exe to connect to MicroStation. I like to wrap the MicroStation interaction code in its own class module. The example class module below will connect a vb.net app with an open session of MicroStation. If you want your app to start MicroStation change the line.

    mApp = GetObject(, APP_OBJECT) 
    to 
    mApp = CreateObject(APP_OBJECT)

    If you are wanting to create a .dll that you load in MicroStation the connection process is different. 

    -------------------------------------------------------------------------------------------------------------------------------------------

    Imports Bentley.Interop.MicroStationDGN

    Public Class clsMicroStationConnection
    Private Const APP_OBJECT = "MicroStationDGN.Application"
    Private mApp As Bentley.Interop.MicroStationDGN.Application

    Public Function Connect() As Object
    Try
    mApp = GetObject(, APP_OBJECT)
    Connect = mApp

    Catch ex As Exception
    Connect = Nothing
    mApp = Nothing
    End Try
    End Function
    End Class

    Rod Wing
    Senior Systems Analyst