11

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.


9

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 ...


9

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 = ...


8

Per @blah238's suggestion, the following script closes ArcMap (if open) creates Add-in installs Add-in silently re-opens ArcMap document Save to directory containing makeaddin.py: import os #Location of ESRIRegAddIn.exe esri = "C:/Program Files (x86)/Common Files/ArcGIS/bin/ESRIRegAddIn.exe" cwd = os.getcwd() mapdoc = <path to mxd> #Close ...


8

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 ...


8

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: ...


7

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.


7

The pythonaddins module has a function to do just this, GetSelectedTOCLayerOrDataFrame(): >>> import pythonaddins >>> sel = pythonaddins.GetSelectedTOCLayerOrDataFrame() >>> print sel Exported_Data >>>


7

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.


6

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 ...


6

Yes you can, you could do it by adding a global variable that keeps track of your clicks. For example: class ToolClass2(object): """Implementation for Test_addin.tool (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" global clickCount clickCount = 0 def onMouseDownMap(self, x, y, button, shift): global clickCount ...


6

I think you can use the addOutputsToMap (=False) property from the env class in arcpy. Further details here: http://resources.arcgis.com/en/help/main/10.2/index.html#//018z0000004s000000


6

You will need to edit your config.xml and add: separator="true" 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....


6

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 ...


5

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 ...


5

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 ...


5

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 ...


5

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: def onClick(self): mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping....


5

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. if focused: self.mxd = arcpy.mapping.MapDocument('current') ...


5

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.


5

There is property isBroken - Returns True if a layer's data source is broken. for layer in arcpy.mapping.ListLayers(mxd, "*", df): if layer.isBroken: arcpy.mapping.RemoveLayer(df, layer) Link to Esri help


5

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. Try: result = arcpy.CreateFileGDB_management(Project_Folder, "FFRA_WRRI.gdb") Output_File_GDB = result.getOutput(0) arcpy.env....


5

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 ...


5

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, ...


4

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 ...


4

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): import arcpy # ...


4

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 ...


4

As of 10.3, there are new attributes on the Extension object that may be of use to you: the Extension.currentLayer and Extension.editSelection properties.


4

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 ...


4

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.


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