Try unchecking the 'Add results of geoprocessing operations to the display' in the Geoprocessing Options in ArcMap.
You can also access this option via the addOutputsToMap property of the env class:
just add arcpy.env.addOutputsToMap = 0 in the beginning of your script.
You can get the coordinates a mouse click via the onMouseDownMap() function of the Tool Class for Python add-ins.
The x and y values for onMouseDownMap and onMouseUpMap represent the map coordinates where the button was pressed or released.
Since you are already creating scripts in Python, it's not much more learning to implement this is an add-in. It's ...
To iterate over the layers in the map, get a reference to the current map document and list the layers within it:
mxd = arcpy.mapping.MapDocument("CURRENT")
layers = arcpy.mapping.ListLayers(mxd):
for layer in layers:
# do something with 'layer'
To just get the number of selected features, try leveraging the Describe object's fidSet property:
desc = ...
An .esriaddin file is just a ZIP-compressed archive containing the files that make up your add-in. You can open it with something like 7-Zip to prove this to yourself. The Essential Python Add-in concepts article hints at this.
The layout of your-addin, including definitions of toolbars, menus and buttons, is all stored within the config.xml, whose syntax ...
As mentioned in the documentation, you can refer to other 'types' by using the appropriate ID.
This is what you set in the wizard when creating the combo-box, button, etc. and you can change it by editing the config.xml file in the root directory of your addin source.
A really simple example that clears a combo-box list when the user presses a button:
You can also deploy addins by copying the .esriaddin file to a network location and telling the addin manager to search this folder.
This location can be added to every PC in your organisation using group policy to set a registry key. See the last section of this page for more details.
The pythonaddins module has a function to do just this, GetSelectedTOCLayerOrDataFrame():
>>> import pythonaddins
>>> sel = pythonaddins.GetSelectedTOCLayerOrDataFrame()
>>> print sel
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 when I searched there for Python AddIns just now.
pythonaddins is limited in reporting and displaying attributes to users. pythonaddins is mainly a way to offer python developers a way to interact with user events. That being said the main mechanism for a developer to display messages to the user is through pythonaddins.MessageBox.
This function takes in a message formatted as a string as the first ...
Yes you can, you could do it by adding a global variable that keeps track of your clicks. For example:
"""Implementation for Test_addin.tool (Tool)"""
self.enabled = True
self.shape = "NONE"
clickCount = 0
def onMouseDownMap(self, x, y, button, shift):
You will need to edit your config.xml and add:
to the button that you want the separator to appear before, like I have done near the end of the line of code below:
<Toolbar caption="RJSS Toolbar" category="RJSS Addin" id="RJSS.toolbar" showInitially="true"><Items><Button refID="RJSS.button1" /><Button refID="RJSS....
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 behavior. Esri has determined that tkinter and Arcmap desktop conflict in their messaging designs and they will not resolve the conflict, so tkinter is not supported ...
Any file included in the Install\ directory of your add-in project will be carried along in the Python add-in when you run makeaddin.py. You can include layer files or anything else really. You'll find the absolute path to them on disk via
path_to_layer = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'mylayer.lyr')
in your whatever_addin.py to ...
Well I couldn't work out how to access the outputs of the script tool from the python addin, but i have achieved the next best thing which works for me. Which was to pass the list from the script in the script tool dialog to a list in the python add in tool.
By importing the python add in tool into the script for the script tool I was able to access the list ...
pythonaddins is limited in getting parameters directly from a user that are not associated with the table of contents as pythonaddins is mainly a way to offer python developers a way to interact with user events. That being said the main mechanism for a developer to get parameters from a user in the same way as arcpy.GetParameterAsText is through ...
It would be better to remove the layer using arcpy.mapping.RemoveLayer. The parameters are the data frame to remove the layer from (possibly a group layer if you are trying to remove from a group) and the layer itself, this alleviates any chance of confusion:
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping....
There is no property that defines the number of items that can be shown in the ComboBox. Instead, use the onFocus method to append the layers in the TOC to the drop-down list.
def onFocus(self, focused):
# When focused, update the combo box with the list of layer names.
self.mxd = arcpy.mapping.MapDocument('current')
If you already packed your addin to an .esriaddin-file (which is nothing but an archive-file similar to ZIP or others) all you have to do is copy the file to your client-PC and install it by double-clicking.
There is property isBroken - Returns True if a layer's data source is broken.
for layer in arcpy.mapping.ListLayers(mxd, "*", df):
Link to Esri help
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 variable is to use the OS module.
result = arcpy.CreateFileGDB_management(Project_Folder, "FFRA_WRRI.gdb")
Output_File_GDB = result.getOutput(0)
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 have been Retired for nearly two years, and that the link you provided states that Python Add-ins were new at 10.1, it doesn't seem likely you'll find a way to ...
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 crashing with one exception.
First, I tried wxPython, but I encountered errors. Then I installed PyQt4 (cp27m‑win32) and after some editings on script like below, ...
I thought this got documented. Since it's undocumented, it's not officially supported, so your mileage may vary, not responsible for damage, etc.
filter is a callable that returns a True/False value as to whether the path specified can be saved to or opened (in the case of OpenDialog). filter_label is what shows up in the filter text in the dialog below the ...
I created a simple script tool using python which does not update an existing field but adds a new field and calculates the acreage. You could just as easily ask the user for the existing field name and update it (using a second parameter in the geoprocessing tool dialog box).
The python file looks like this (Creating a new Python script):
To try and understand your Question, I have reviewed the Creating a Python Add-In Combo Box help page to remind me that ...
A combo box contains an editable field and a drop-down list. The user
can select a value from the drop-down list, which appears at the
user's request. If you make the combo box editable, the combo box will
include an editable ...
So, just to follow up on what Luke said, I created (see below) a very simple example that makes a pull-down of current map layers, which can be easily modified to list something else and act on the selection.
The workaround mentioned executes with onEnter so that the last selected val is reset in the combobox. Some comments and print statements left in for ...
I've never used Python Addins but the interface you describe is a Script Tool. A discussion about calling Script tools from Addins is found here. As @Barbarossa comments above you can use tool validation to populate the parameters. Unless there is a specific reason for creating a Python Addin I would probably stick to creating a Python Script Tool.