Article directory
0 Preface
ArcGIS plug-in (Add-ins) can make it easier for users to customize and extend ArcGIS Desktop applications. It creates a series of custom tools to provide an open basic framework, packaged and compressed into a single file. Add-ins can be easily shared among users because they require neither an installer nor Component Model (COM) registration. This article records the process of implementing Python-based Arcgis plug-in development.
1. Prepare the Python add-in tool
Download the Python Add-in Wizard.
Python add-in wizard download link: https://desktop.arcgis.com/zh-cn/arcmap/10.4/analyze/python-addins/creating-an-add-in-project.htm
2. Create an add-in tool
(1) Create a working directory
After decompressing the "Python Add-in Wizard", create a working directory named "work2" in the addin_assistant directory to store the plug-in project files.
(2) Execute addin_assistant.exe and specify the working directory as work2
(3) Basic project information settings
(4) Plug-in content settings
① Create a work bar
② Create a button
③Description of files in the working directory
3. Write code
Open work2_addin.py in the Install directory to write business code
def onClick(self):#将选择的对象缩放到全图
mxd =arcpy.mapping.MapDocument('current')
df =arcpy.mapping.ListDataFrames(mxd)[0]
df.zoomToSelectedFeatures()
4. Generate installation files
Run makeaddin.py in the Python environment to generate the installation file.
This article runs under the Python tool that comes with Arcgis.
Results of the:
5. Install and call out add-ins
①Double-click work2.esriaddin to install the add-in
② Call up the add-in
6. Use add-ons
References:
[1] GIS hum ha ha. Create a simple arcgis python-addin plug-in ; 2020-06-01 [accessed 2023-07-07].
[2] yycGIS. ArcGIS Desktop python Add-in Create a plug-in ; 2014 -04-02 [accessed 2023-07-07].
[3] ArcGIS official website. Get Python add-in wizard ; [accessed 2023-07-07].
[4] weixin_39995439. python in arcgis_ArcGIS Desktop python Add-in Create a plugin ; 2020-11-24 [accessed 2023-07-07].