New answers tagged

3

You have some repeating processes that could probably be rearranged. It may help with speed. Clearing all the layers' selections could be done at the beginning of the loop instead of within each if/else statement Edit (this may slow down the process since the clear selection happens every iteration): if count == 1: with arcpy.da.SearchCursor(table, ...


1

Based off your code, it sounds like you're trying to disable a button rather than an entire toolbar. Instead of WTF_toolbar.enabled = False do fish_button.enabled = False to disable the button. Same goes for WTF_toolbar.enabled = True. More info here


0

You can simplify your code somewhat by using: df = self.mxd.activeDataFrame layer = r'G:\Gis\DATEN\wvdat\Querbauwerke\Fischaufstieg.lyr' if arcpy.Exists(layer): layerToAdd = arcpy.mapping.Layer(layer) arcpy.mapping.AddLayer(df, layerToAdd, 'TOP') else: warningButton = pythonaddins.MessageBox("warning") You might also want to set the mxd ...


0

Moved from a comment to an answer and expanded a little, as per @polygeo's suggestion. I'm not sure you can use startfile to launch a python file. You need to ensure the environment variables are setup. Why not just package it with your addin and import it to call the function directly? Also, Layer() doesn't accept a shapefile only lyr files. You need ...


2

Without seeing how you put your vertices list together, this code works and might provide some assistance: import arcpy vertices = [arcpy.Point(298650.871, 7342809.718), arcpy.Point(298653.147, 7342809.824 ), arcpy.Point(298653.041, 7342807.972), arcpy.Point(298650.924, 7342807.972 )] # Create a polygon geometry array = ...


1

I have seen this in the past - happened on half of our work PCs one day and we never did find the cause, however we did find a work-around. Instead of loading our add-ins into the default location (My Documents I think) we set up Additional Add-In folders in ArcMap and copied our Add-In files there, and they work fine. We didn't have to put all add-ins ...


1

Usually I see this if the Windows environmental variables aren't set up correctly. Try: Start command prompt (go to Start Menu ---> Run ---> type cmd) Type python, and then import arcpy (shown below) Does everything work without errors? If you get an error, then try: Right click on My Computer and go to Properties, then click on the Advanced ...


3

I ran a test for this and it works fine if there are no bugs in the code. Indentation errors (as @Ken points out) will not show up as an error on the toolbar but the tool won't run. There must be some little error in your python file that isn't being detected. Your code should resemble this: import arcpy import pythonaddins class ButtonClass1(object): ...



Top 50 recent answers are included