khan18

Import functions in python Add-In logic script

Discussion created by khan18 on Jan 31, 2013
Latest reply on Feb 1, 2013 by achapkowski-esristaff
I am running into an error. I have a set of functions which I want to import in the python Add-In script at the time of execution, but when I built Add-In with "import stats" line then tools are unresponsive. Any suggestions whether it is possible to import functions in the Add-In script?

import arcpy
import os
import pythonaddins
import stats

optfolder = "C:/temp"

class AoI(object):
"""Implementation for rectangle_addin.tool (Tool)"""
    def __init__(self):
        self.enabled = True
        self.cursor = 5
        self.shape = 'Rectangle'
        os.makedirs(optfolder)

    def onRectangle(self, rectangle_geometry):
   """Occurs when the rectangle is drawn and the mouse button is released.
    The rectangle is a extent object."""

        extent = rectangle_geometry
        arcpy.Clip_management(r'C:/temp/ras', "%f %f %f %f" %(extent.XMin, extent.YMin, extent.XMax, extent.YMax),
                              optfolder + '/ras1', "#", "#", "NONE")
        arcpy.RefreshActiveView()

Outcomes