Select to view content in your preferred language

ArcGIS 9.2: can I let a Python script use the work space of the current ArcMap file?

886
3
12-07-2010 11:18 AM
SuiHuang
Frequent Contributor
Hi Everybody:

    I am writing a python script to perform data validation for data editor using ArcMap, and want to make it into a tool in ArcToolbox.
    If the tool is executed from ArcMap with a MXD file open, is it possible to let it detect the active data connection in the MXD and directly use it to retrieve data?
    Thank you.
Tags (2)
0 Kudos
3 Replies
StephenBarrow
Emerging Contributor
Hi Everybody:

    I am writing a python script to perform data validation for data editor using ArcMap, and want to make it into a tool in ArcToolbox.
    If the tool is executed from ArcMap with a MXD file open, is it possible to let it detect the active data connection in the MXD and directly use it to retrieve data?
    Thank you.


Try
import arcpy.mapping
print arcpy.mapping.MapDocument("CURRENT").filePath
0 Kudos
markdenil
Frequent Contributor
Yes, but one cannot evoke arcpy from 9.2, and acgisscripting does not provide access to the arcpy.mapping module.
I do not think this can be done from Arc9.2 in python without accessing ArcObjects.
0 Kudos
BruceNielsen
Frequent Contributor
It should be possible to add some VBA code to either an MXD or a user's Normal.mxt that would set an environment variable to the project's source path. That variable could then be read with os.environ.
0 Kudos