Pythonaddins not working for ArcGIS 10.3.1

4211
5
06-08-2015 10:48 AM
YaminNoor
New Contributor

Hi,

I wrote a python tool using pythonaddins in ArcGIS 10.1. The tool works perfectly on ArcGIS 10.1 and 10.2. But I am unable to run the tool on ArcGIS 10.3.

Here is my python code snippet:

def onMouseDownMap(self, x, y, button, shift):
        #setup workspace location
        arcpy.env.workspace = r"" + self.inFile 
        #list all rasters
        rasters = arcpy.ListRasters("*", "TIF")
        #CSV file
        csv_file = arcpy.env.workspace + "\output.csv"
        #define output rows list
        rows = []
        #define output layers list
        layers = []
        #loop through all raster files and get cell values
        for raster in rasters:
            result = arcpy.GetCellValue_management(raster, "{} {}".format(x, y), "1").getOutput(0)
            layers.append("{}".format(raster))
            rows.append("{}".format(result))
        #open the csv file and append values for each click on the raster map
        with open(csv_file, 'a') as outcsv:
            
            #configure writer to write standard csv file
            writer = csv.writer(outcsv, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
            #print x, y in csv
            writer.writerow(['x', 'y'])
            #print x, y location in csv
            writer.writerow([str(x), str(y)])
            #print Layer, Value in csv
            writer.writerow(['Layer', 'Value'])
            #get row length
            rowlen = len(rows)
            #loop through the rows and print output to csv
            for i in range(0, rowlen):
                writer.writerow([layers, rows])

And here is my config.xml file look like:

<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Name>GetRasterCellValue</Name>
    <AddInID>{c509440b-c55e-46bb-b443-a61a2b824da2}</AddInID>
    <Description>A python addins tool to get cell value of raster files</Description>
    <Version>0.1</Version>
    <Image>Images\Other.png</Image>
    <Author>Yamin Noor</Author>
    <Company>XYZ</Company>
    <Date>06/08/2015</Date>
    <Targets>
        <Target name="Desktop" version="10.1" />
    </Targets>
    <AddIn language="PYTHON" library="GetRasterCellValue_addin.py" namespace="GetRasterCellValue_addin">
        <ArcMap>
            <Commands>
                <Tool caption="GRCV" category="GetRasterCellValue" class="GRCV" id="GetRasterCellValue_addin.GRCV_1" image="Images\Other.png" message="Get Raster Cell Value" tip="Use this tool to get raster cell value">
                    <Help heading="Get Raster Cell Value">Get Raster Cell Value</Help>
                </Tool>
            </Commands>
            <Extensions></Extensions>
            <Toolbars>
                <Toolbar caption="GRCV" category="GetRasterCellValue" id="GetRasterCellValue_addin.GRCV" showInitially="true">
                    <Items>
                        <Tool refID="GetRasterCellValue_addin.GRCV_1" />
                    </Items>
                </Toolbar>
            </Toolbars>
            <Menus></Menus>
        </ArcMap>
    </AddIn>
</ESRI.Configuration>

I am not sure if changing the target version (to 10.3) in config.xml would make any difference. i.e

<Target name="Desktop" version="10.1" />

Thanks
Yamin

Message was edited by: Yamin Noor

0 Kudos
5 Replies
AlexanderNohe1
Occasional Contributor III

Have you tried changing line 11 in your config.xml to:

<Target name="Desktop" version="10.3" /> 

This would reflect the current release that you are on.

What is the exact problem that you are having with your addin?  Is it just not loading or something else?

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Hi Yamin,

ArcGIS 10.2 was backward compatible with 10.1. So, the Add-ins built in 10.1 worked with 10.2, but ArcGIS 10.3 is not backward compatible with 10.1.

Maybe the Python experts can help you get out of it.

cc Xander BakkerDan Patterson



Think Location
0 Kudos
DanPatterson_Retired
MVP Emeritus

I doubt it would be as simple as changing the xml.  Perhaps the differences are like the transition from ArcView 3.x upward (worst case scenario) or the horrendous well-know location where add-ins are looked for.  It can't be python assuming that both use python 2.7.  It has to be more difficult than that​

0 Kudos
MarkWarren1
New Contributor II

Dan, you are correct: it was not as simple as changing the xml and rebuilding the Addin.  Did that and still having problems.  Biggest problem is that the Python Addin will absolutely not work now from a shared network Addin folder.  Installing the Addin from the local C: drive will get it to work for a while, but it inevitably fails after running a few times, which then requires a restart to clear things out so the tool will begin running again.  Same Addin had been running without problem in 10.2 for a couple of years prior to our recent ArcGIS 10.3.1 upgrade.

0 Kudos
YaminNoor
New Contributor

Mark,

No its still not working for me on ArcMap 10.3+ but works on ArcMap 10.1 and 10.2. I now have another issue to deal with pythonaddins tool. I developed another separate tool to create rectangle fishnet. It works like charm but after exactly 9 clicks on the map ArcMap crashes to desktop. I have tested this on ArcMap 10.1 and 10.2.

Yamin

0 Kudos