Skip to main content
7 votes

Getting layer name of selected features with ArcPy?

The pythonaddins module has a function to do just this, GetSelectedTOCLayerOrDataFrame(): >>> import pythonaddins >>> sel = pythonaddins.GetSelectedTOCLayerOrDataFrame() >>>...
Chad Cooper's user avatar
  • 12.7k
7 votes

Where to download python add-ins?

ArcGIS Code Sharing seems to be the site that you are looking for. It claims to enable you to: Search, browse, and use code, scripts, models, add-ins, widgets, and more. There were 48 results ...
PolyGeo's user avatar
  • 65.3k
6 votes

ArcGIS crashing with Tkinter?

Tkinter is not compatible with any version of Arcmap desktop. As a script you are running pure python, and not using the ArcMap desktop application at all, which is why you are seeing different ...
Richard Fairhurst's user avatar
6 votes
Accepted

ArcMap crashing when plotting features with matplotlib few times via Python AddIn?

I think, It's most probably about Python GUI (especially Tkinter). Matplotlib uses Tkinter by default. I couldn't figure it out why, but If I change GUI package for matplotlib to PyQt4, no more ...
Kadir Şahbaz's user avatar
5 votes
Accepted

unable to change the work space using arcpy

I had this problem before. There are two solutions: You need to set the result of the geoprocessing tool "CreateFileGDB" as a variable using arcpy.getOutput method. Another way to set the GDB ...
MacroZED's user avatar
  • 2,291
5 votes
Accepted

ArcGIS 10.0 Addin install error?

The documentation states: Add-ins are not backward compatible. Add-ins targeting 10.1, for example, will not work with 10.0 but will work with 10.2. Considering that ArcGIS 10.0 is old enough to ...
Vince's user avatar
  • 20.2k
4 votes
Accepted

ArcGIS crashing with Tkinter?

I think the trick to using tkinter in Python is to run it from an external module, that way it isn't competing with the GUI components from the pythonaddins module. I do not take any credit for the ...
crmackey's user avatar
  • 8,514
4 votes
Accepted

Error Handling within Python AddIns?

You can avoid ERROR 000725: Table Name: Dataset editViewStormBill already exists. by setting arcpy.env.overwriteOutput = True Otherwise you can use arcpy.ExecuteError to catch the exception and arcpy....
user2856's user avatar
  • 67.7k
4 votes

How to terminate ArcMap add-in script?

That's cool, I didn't know you could shutdown Arc by calling sys.exit(). The in-program python interpreter shuts down with the exit call and since the ArcGIS is depended on it the action shut downs ...
nickves's user avatar
  • 11.6k
4 votes
Accepted

Adding error message to python add-in?

As per the documentation, you have to use the pythonaddins.MessageBox(). pythonaddins.MessageBox("your error message", "Error", 0)
crmackey's user avatar
  • 8,514
4 votes

Pythonaddins combobox advanced functionality

I doubt you can use timer in addin seamlessly. If possible, I want to learn, too. However, you can use onFocus() function of combobox. This is not a perfect solution, but it might be helpful. class ...
Kadir Şahbaz's user avatar
4 votes
Accepted

Pythonaddins combobox advanced functionality

I've not had much call in developing Python AddIns but what you were asking is something I would have approached in VB .net using an extension with an event firing on something specific. If you look ...
Hornbydd's user avatar
  • 44.1k
3 votes

Problem with layer name

You have not set the LayerName correctly. At the moment, LayerName is only the name of the dataset. Its it not the full path to the dataset. You need to identify the actual layer object when using ...
MacroZED's user avatar
  • 2,291
3 votes

Getting layer name of selected features with ArcPy?

You may be able to modify this to suit your requirements. This loops through all layers in your MXD and checks if there's a selection. If it finds a layer with a single selected feature it will ...
Midavalo's user avatar
  • 29.9k
3 votes

Setting selection method in ArcPy?

arcpy.SelectLayerByAttribute_management and arcpy.SelectLAyerByLocation management both have the optional parameter Selection Type. The value must be one of the following strings: "NEW_SELECTION" "...
Ali's user avatar
  • 4,075
3 votes

Setting selection method in ArcPy?

While not answering the specific question, I try to aim at the functionality the OP is seeking. I often use these different selection methods myself, and for convenience I have added a dropdown list ...
Martin's user avatar
  • 4,938
3 votes
Accepted

Select Features grayed out in PythonAddins toolbar

Your problem is that you are adding an item that is not the same as the Select Features on the Tools toolbar. The Select Features from the Data View Context Menu is the tool that one can start once ...
Alex Tereshenkov's user avatar
3 votes
Accepted

Creating multiple points, using Python AddIn?

You're recreating the same feature class each time you use the Copy Features tool. As mentioned in the comments, you can use an insert cursor instead to add the feature to an existing feature class. ...
Emil Brundage's user avatar
3 votes
Accepted

Executing add-in from Python script?

You do not say where you wish to run your Python script but, in any event, since Python AddIns only work from within ArcMap I think the approach you should take is to absorb the code from that addin ...
PolyGeo's user avatar
  • 65.3k
2 votes

Setting selection method in ArcPy?

Yo can do selection by both attribute using arcpy.SelectLayerByAttribute_management and location using arcpy.SelectLayerByLocation_management, but you cannot do selection directly from feature, you ...
ahmadhanb's user avatar
  • 41.2k
2 votes

ArcGIS 10.2 with MatPlotLib Non-Blocking Plot

This is an issue with Tk's event loop conflicting with ArcGIS. TK expects that it is the only GUI loop running in the process. The only real 'work-around' (and more of a band-aid in my opinion) I've ...
Evil Genius's user avatar
  • 6,289
2 votes

Waiting for a python script tool to complete while using pythonaddin button

I have been having this exact same problem (using ArcPy 10.4.1) and came up with a workaround. What I did is create a new tool (I'm calling it "new_tool") to serve as a wrapper for the ...
Chris's user avatar
  • 21
2 votes
Accepted

Python Add-In will not run

Your indentation appears wrong and I am not sure why you have left pass in there. I also think the time.sleep() will be unnecessary. To get further try using: class RoadJoin(object): """...
PolyGeo's user avatar
  • 65.3k
2 votes
Accepted

Importing Functionality from Python Addin into script

The Curves and Lines add-in is not a python add-in. It is probably a .Net ArcObjects add-in. I determined this by downloading the add-in and extracting the files using an unzip application. Inside ...
Midavalo's user avatar
  • 29.9k
2 votes

Getting layer name of selected features with ArcPy?

Regarding to my old Answer: You can extend it to get what you are looking for: mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd) lyr = arcpy.mapping.ListLayers(df[0])...
riflo's user avatar
  • 1,155
2 votes
Accepted

Turning first vertex of a line into a point

You're almost there. In this line: pt_cur = arcpy.da.InsertCursor(Point Feature Here, ['SHAPE@']) Change the list containing only 'SHAPE@' to a list of the fields you want to update (including '...
Fezter's user avatar
  • 21.9k
2 votes

Arcpy deselect layer in TOC

I do not think this method exists in arcpy. You may have to call the IContentsView.RemoveFromSelectedItems arcobject method using python to call comtypes objects. This old code sample shows how to ...
artwork21's user avatar
  • 35.2k
2 votes

Unable to add toolbar in Python addin wizard

The help page Creating an add-in toolbar says: Once you have entered the required project settings, click on the Add-In Contents tab. To create a new toolbar, right-click on TOOLBARS and click ...
PolyGeo's user avatar
  • 65.3k
2 votes
Accepted

Tool in Tool Palette as a parameter for Button

This should work: par = '' class ONE(object): """Implementation for SelectNlevelTest_addin.ONE (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" ...
Serge Norin's user avatar
2 votes

ESRI Add-In is [ MISSING ]

This happens when the add-in encounters errors on initialisation. If you have the Python window open before loading your toolbar any exceptions will be reported there and should point you in the right ...
Ali's user avatar
  • 4,075

Only top scored, non community-wiki answers of a minimum length are eligible