Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: bentley.interop.microstationdgn.dll for Python

$
0
0

Hi Peter,

[quote user="peter bojarov"]I use Python 2.7.6[/quote]

it's still not clear what Python do you use :-(

Python 2.7.6 can be both "classic Python" (CPython) and IronPython. They are very different Python interpreters offering different features. Also "import clr" does not help to investigate what do you use, because the same command uses Python for .NET and IronPython.

[quote user="peter bojarov"]I suppose my application should be in-Process[/quote]

I guess it cannot be. If you use Application object, you connect from your code to another application, so you control one process (application) from another.

[quote user="peter bojarov"]I am getting TypeError: 'interface takes exactly one argument'. Does someone knows that I should do to make it work?[/quote]

To find solution, you should understand what the error tells you: It's about interface ... but interface cannot be instantiated (as defined in NET).

In C# and VB.NET the most straightforward way how to start MicroStation instance and to connect to it is

Application ustnApp = new Bentley.Interop.MicroStationDGN.ApplicationClass();

and I ugess it will be similar in Python. As you can see, the ustnApp is Application (which is interface), but you have to instantiate ApplicationClass (which is class).

I recommend:

  • Check Connecting to MicroStation from a Separate Process chapter in MicroStation VBA help. There are some differences if connecting though interop, but it gives good overview how the connection can be made.
  • Use e.g. Visual Studio or some decompiler to study and understand Bentley.Interop.MicroStationDGN assembly API and to distinguish what is interface and what is class.

[quote user="peter bojarov"]I would be very happy if I could access ActiveMicrostationDGN Application and ActiveDGNfile and use VBA API commands from Python[/quote]

I don't remember it was discussed in the past, so unfortunately you will have to test it yourself. In general the access to MicroStation from Python should not be different from any other language, I guess you can use Interop (which is NET interoperability technology that can be used by not managed code) or to write NET addin (managed language, IronPython?, has to be used).

With regards,

  Jan


Viewing all articles
Browse latest Browse all 7260

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>