1

I am trying to come up with a python script that will go through a designated folder, locate all MXD files within the folder, and then check each MXD to see if it contains a specified shapefile, which should be replaced with another shapefile if it is found. I am working in ArcGIS 9.3 so arcpy.mapping is not available to me.

I have heard that ArcObjects might help but I don't know that much about it and am not sure if it would be feasible with my modest python experience.

Any Suggestions?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Soupoder
  • 61
  • 4

2 Answers2

1

To "go through a designated folder, [and] locate all MXD files within the folder" is relatively easy with Python, and there is a Stack Overflow Q&A that describes some ways:

https://stackoverflow.com/questions/3207219/how-to-list-all-files-of-a-directory-in-python

However, the rest is much harder because ArcGIS Desktop 9.3 only had access to the arcgisscripting module, and this did not have any equivalent to the arcpy.mapping module which you would need to make Updating and fixing data sources easy.

I would expect that it would be possible to do this using ArcObjects accessed from Python but it is not something that I would consider trying to do personally.

I think you will need far more than "modest python experience" to use the Q&A below to try and achieve what you describe.

Accessing ArcObjects from Python?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
0

I have been down that route and I don't suggest it. When I started to run Arcobjects with Python (almost 2yrs ago), I only knew a little bit of C#, but had what I would consider a modest knowledge of Python. Not a pro, but not a beginner either. Now, I am switching the whole Add-In (3k-ish lines of code) to C# as it will be developed further and it's not worth keeping it in Python.

It works, but it's difficult to work with. The hardest thing is debugging and knowing what parameters you need to give the method calls and instantiating objects. When something goes wrong it's really hard to know what's wrong and what to do about it. Putting the time into learning C# would have made more sense in the long run. But it's how I cut my teeth on programming and did make it much easier to learn C# once I finally bit the bullet...

One of the trickiest parts for me was getting it all setup properly. The link @PolyGeo gave is the right place to start. If you can get it setup, then you'll be fine.

However, learning new languages will be beneficial to you down the road in a lot of different ways. All of the Arcobjects API examples are in C# and you are going to be getting really, really, friendly with the API. If you go with C# and Visual Studio, the intellisense is really great, especially when you are learning the API. So I would suggest you use this as an opportunity to diversify.

cndnflyr
  • 3,392
  • 2
  • 25
  • 43