How does ArcGis develop plug-ins through Python?

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
  insert image description here

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.
  insert image description here

  (2) Execute addin_assistant.exe and specify the working directory as work2
  insert image description here

  (3) Basic project information settings
  insert image description here

  (4) Plug-in content settings
  ① Create a work bar
  insert image description here

  ② Create a button
  insert image description here

  ③Description of files in the working directory
  insert image description here

3. Write code

  Open work2_addin.py in the Install directory to write business code
  insert image description here

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.
  insert image description here

  This article runs under the Python tool that comes with Arcgis.
  insert image description here

  Results of the:
  insert image description here

5. Install and call out add-ins

  ①Double-click work2.esriaddin to install the add-in
  insert image description here

  ② Call up the add-in
  insert image description here

6. Use add-ons

  insert image description here

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

Guess you like

Origin blog.csdn.net/qq_40640910/article/details/131592230