I am having an syntax error from Pyscripter here and not sure why but I have a shapefile at the top of the TOC list which is the first and should be number zero when writing a listlayers as a zero but I still get the error .
The error is :
Traceback (most recent call last):
File "C:\Student\python\GeoTIFF.py", line 16, in <module>
gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0]
IndexError: list index out of range
Take a look here the sytanx:: gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0]
My Pyscripter versions is 2.5.3.0 x86 Is that correct for ArcGIS 10.1 Python 2.7 ?
You should be OK with that version of PyScripter (it hasn't been updated in years). If it was installed after ArcGIS, it will probably find the python installation that comes with ArcGIS in C:\Python27\ArcGIS10.1.
You can check the Python path in the Tools menu to see which paths are used.
When you run some simple code like:
import arcpy print arcpy.ProductInfo()
It will print the license level of ArcGIS. If this works you can work with PyScripter and ArcGIS.
In you code you reference the mxd document by path instead of using the keyword "CURRENT".
That is all it takes as Jake Skinner already explained.
Running the code from as stand alone script (from output ArcMap) will open the MXD on the background and process it. There is not much more to it...
Thanks. I went back to Pyscripter and try again and change from gridlayers to imagelayer
Now I see that ListLayers had the errror so I am thinking that by looking at the Varibales and it is not there...
is that why it could not run it ?
Never mind. I did checked and ListLayers still there and I think the main problem is I copied and paste when I first started and gave me bunch of problems so I am thinking instead of copy and past . I might have to do typing rather than copy and paste ?
What do you say ?