Monday, May 30, 2005
- Python and ArcObjects via .NET
I noticed that the Python for .NET project (perhaps better termed .NET for Python, to avoid confusion with IronPython) has reached release candidate status. This project is by Brian Lloyd of Zope. It enables the standard Python interpreter (CPython) to access the .NET Framework.
The interesting thing about this (other than the obvious) is that ESRI maintains customized primary interop assemblies for all of ArcObjects. These ESRI-maintained assemblies take care of all of the differences between the COM typelib description and the actual usage pattern - things like whether a reference value is meant to be used as a pointer to an array, or as a single value. (SAFEARRAYs are rarely used in ArcObjects. The reason probably has something to do with performance, or just with streamlining C++ development.) It is those kinds of differences that make it especially troublesome to auto-generate a binding between ArcObjects and Python (something I tried to do a few years ago, but abandoned). But since ESRI does all of the manual labor for .NET, we can leverage that using Python for .NET (sic).
I have done some testing, and found that the release candidate now works with a stock Python interpreter. That feature was broken in beta 5; it only worked with the patched interpreter included in the beta. In addition, the import hook now seems to work much better: no more need to "prime" the .NET bridge with
I haven't yet tested with the ArcObjects primary interop assemblies for .NET. The platform where I do most of my open source work doesn't have ArcGIS 9 on it. However, at beta 3 it worked fine once I made a few tweaks here and there (which I submitted to Brian, and which he included in a later beta).
If you want to test the release candidate, use the IDLE IDE or the console. Or, if you prefer PyWin32 / PythonWin, copy Python.Runtime.dll into
lib/site-packages/pythonwin, next to
This article is definitely not about me - my contributions to this project were small. Nevertheless, I will close out by mentioning one other small thing that I'm doing. I maintain an integrated setup wizard for Python and Win32 Extensions. It's just a small project, with only a few users. Once Python for .NET is released, I plan to start including that in the package. I will publish a beta of this soon, using the current release candidate.
Hello, I'm a student with beginning/intermediate vb.net and python skills. I'm looking for examples of Python for .net being used with ArcObjects. Did you ever test this with success. Any information would be helpful. Thank you!
Mar 8, 2006 1:25:00 PM