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()
>>>...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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)
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 ...
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 ...
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 ...
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 ...
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"
"...
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 ...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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):
"""...
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 ...
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])...
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 '...
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 ...
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 ...
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"
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python-add-in × 279arcpy × 236
arcgis-10.1 × 55
arcmap × 47
arcgis-desktop × 44
arcgis-10.2 × 35
python × 21
combo-box × 20
arcgis-10.3 × 19
python-2.7 × 14
python-script-tool × 13
arcgis-10.4 × 11
tkinter × 8
toolbar × 6
wxpython × 6
enterprise-geodatabase × 5
editing × 5
select-by-attribute × 5
qgis × 4
point × 4
layers × 4
select × 4
coordinate-system × 3
arcobjects × 3
symbology × 3