Why is my toolbar showing all "Missing" tools/buttons?

المشرف العام

Administrator
طاقم الإدارة
I am horribly new to coding with python. I made a toolbar using the wizard and old bits of VBA code. I created a button to search by map number, a tool to calculate area from UI and a second tool that would clear the area selected.

I get the following icons when I install the add in to test.


The following is what I have for my code:

import arcpy import sys import os import pythonaddins class ZoomToMapNumber(object): """Implementation for Test Addin_addin.button (Button) Everything from Import to del mxd is external code / deleted pass after 2nd def""" def __init__(self): self.enabled = True self.checked = False def onClick(self): mapno = sys.argv[1] mxd = arcpy.mapping.MapDocument("Current") lyr = arcpy.mapping.ListLayers(mxd,"SDEOWNER.MapIndex")[0] arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "\"MAPNO\" = " + str(mapno)) result = int(arcpy.GetCount_management(lyr).getOutput(0)) arcpy.AddMessage("Number of selected records: " + str(result)) if result > 0 df = arcpy.mapping.ListDataFrames(mxd)[0] df.zoomToSelectedFeatures() arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION") del df else: arcpy.AddError("No record selected for map number " + str(mapno)) del lyr del mxd class CalcDrainArea(object): """Implementation for Test Addin_addin.tool (Tool)""" def __init__(self): self.enabled = True self.shape = arcpy.polygon(inputs) # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks. inputs = [] def onMouseDownMap(self, x, y, button, shift): # Inputs x,y coordinate pair to inputs for every mouse click for coordinate_pairs in (x, y): inputs.append(x, y) def onDblClick(self, x, y, button, shift): # Inputs the final x,y pair and the first x,y pair as last four values into the 'inputs' array final_x = inputs[0] final_y = inputs[1] inputs.append(x, y) inputs.appent(final_x, final_y) return inputs def calc_drainage_area(inputs) #takes (x1, y1, x2, y2, ... xn, yn) cArea = 0 # Calculate the area based on the Surveyor's formula for i in range(0, len(x)-1): cArea = cArea + x*y[i+1] - x[i+1]*y cArea = abs(cArea / 2) class ClearArea(object): """Implementation for Test Addin_addin.tool_1 (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks. mxd = arcpy.mapping.MapDocument("Current") for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): elm.delete() arcpy.RefreshActiveView() del mxd

أكثر...
 
أعلى