Select to view content in your preferred language

Accessing ArcMap 9.3 elements in python

637
3
02-03-2011 02:50 AM
AllanLumte
New Contributor
Hi There,
Am trying to access elements (layers, display information, symbology) in an arcmap 9.3 document  through the geoprocessor object in python. setting the mxd as a workspace isnt working

gp = arcgisscripting.create()
gp.Workspace = "C:/MXD/tourmap"
Tags (2)
0 Kudos
3 Replies
LukeBadgerow
Deactivated User
As I understand it you can't at 9.3.

Have a look at the below link for the fly-over:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=905&pid=904&topicname=About_getting_started_w...

Best I have been able to do is when you set your UI up for your script within ArcMap/ or ArcCatalog set your input parameters to be of the Feature Layer type as opposed to being of either shapefile or feature class.  This will allow the tool validator class to reach over and grab from either the TOC or the catalog tree view with a drag/drop operation.

I'm told (got to see the demo for it at the dev summit last year) that you can manipulate all of that @10 with the ArcPy libraries, but I haven't had a chance to play with it yet.

Best of Luck
0 Kudos
BradPosthumus
Frequent Contributor
Hi There,
Am trying to access elements (layers, display information, symbology) in an arcmap 9.3 document  through the geoprocessor object in python. setting the mxd as a workspace isnt working

gp = arcgisscripting.create()
gp.Workspace = "C:/MXD/tourmap"


A workspace is a location that stores data, not an MXD. The only way is access MXD information in 9.3 with Python is through the ArcObjects library via the Python module comtypes.

There's a good powerpoint presentation about Python and ArcObjects here:
http://www.pierssen.com/arcgis/misc.htm

and a couple of recent posts here:
http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python
http://forums.arcgis.com/threads/21348-How-do-you-refresh-view-in-ArcMap-from-Python

If you're familiar with ArcObjects and its object module then you can likely pick it up fairly easily. If you're new to ArcObjects you're best off practicing with it in VBA first - it takes awhile to understand it and VBA makes it a bit easier. There's plenty of examples in these forums to do what you want with ArcObjects in VBA.

As Luke mentions, the ArcPy module in ArcGIS 10 makes it easier to access most MXD information. However..... I'm still waiting for 10 but in the meantime I've been going over the documentation and I still don't see any way to access and manipulate layer symbology.
0 Kudos
AllanLumte
New Contributor
Alright, i ditched 9.3 for arcgis 10 evaluation edition which will last for the duration of my project.
Arcpy library in 10 is really helpful for accessing mxd dataframe and layer elements. Thanks for the suggestions!
0 Kudos