Python Addin - AddInId

388
4
12-07-2018 07:02 AM
ChrisHolmes
Occasional Contributor III

Hello all,

I have a python addin which I have made a copy of then made a few changes to the copy. I would like to have both addins loaded in arcmap but for some reason only one addin will display. 

I'm wondering if it could be because both addins have the same AddInId value:

You can see in this picture from ArcMap that one toolbar is installed but both are showing in the Add-In Manger.

Any thoughts appreciated.

Thanks!

Tags (2)
0 Kudos
4 Replies
RandyBurton
MVP Regular Contributor

After making a copy and making a few changes did you run the makeaddin.py script?  If you did, could you provide a few more details about the copy/update/install process you used?

From Essential Python add-in concepts:

The makeaddin.py Python file is a utility script created by Python Add-In Wizard and is used to package the files and folders within the project folder into the compressed add-in file. Double-click this file to create the add-in file. Each time you make changes to the add-in, you must run this script to repackage the add-in file with the latest updates.

0 Kudos
ChrisHolmes
Occasional Contributor III

Hi Randy,

Yes I did run makeaddin.py and then I copied the .esriaddin file into a well known folder. I have 2 .esriaddin's that I want to install 1) agendamapping.esriaddin and 2) agendamappingsql-dev.esriaddin

Here are a few examples of what I'm seeing:

  • when I have only one of the .esriaddin files in the well known folder then I see that addin installed correctly in arcmap:
    • agendamapping.esriaddin:

               

  • agendamappingsql-dev.esriaddin:

               

  • If I put both of the .esriaddin files into the well known folder then only the 'Agenda Mapping SQL DEV' displays

Interesting though, when both .esriaddin files are in the well known folder if I select Customize > Add-In Manager, I see both addins listed:

Thanks for any help!

0 Kudos
RandyBurton
MVP Regular Contributor

I have doing some experiments with add-ins, and I think you are partially correct that the problem is with the AddInID.  Testing an add-in mentions one use of the AddInID:

The installation utility copies the add-in file to a generated subfolder under the default add-in folder; the subfolder is automatically generated using a globally unique identifier (GUID). This prevents file naming conflicts that might occur if several add-ins have the same file name. Although add-ins can be manually copied to a default add-in folder, doing so bypasses the security and name conflict checks the add-in installation utility performs.

Additionally in the add-in's XML, there are some other items that affect the add-in's operation.  With the  Add-In Wizard I created the start of an add-in.

Add-In Wizard

The XML generated by the wizard looks like this (note the red dots above and where it appears in the XML):

<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>Version2</Name>
  <AddInID>{6f8bf92b-918d-440f-9fb8-e2cb53bc5f44}</AddInID>
  <Description>Some description text</Description>
  <Version>0.1</Version>
  <Image />
  <Author>Author's name</Author>
  <Company>Author's company</Company>
  <Date>12/13/2018</Date>
  <Targets>
    <Target name="Desktop" version="10.1" />
  </Targets>
  <AddIn language="PYTHON" library="Version2_addin.py" namespace="Version2_addin">
    <ArcMap>        
      <Commands>        
        <Tool caption="Version 2" category="Version2" class="Class2" id="Version2_addin.tool" image="" message="Some message text" tip="Text of tip">
          <Help heading="Some heading text">Some help text</Help>
        </Tool>
      </Commands>        
      <Extensions></Extensions>
      <Toolbars>        
        <Toolbar caption="Toolbar2" category="Version2" id="Version2_addin.toolbar" showInitially="true">
          <Items>
            <Tool refID="Version2_addin.tool" />
          </Items>
        </Toolbar>    
      </Toolbars>
      <Menus></Menus>
    </ArcMap>
  </AddIn>
</ESRI.Configuration>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I think some of the problem might also relate to the duplication of the names (the red dots).

My recommendation when you want to copy and modify an add-in is to:

  1. Create an empty folder for the new add-in.
  2. Open the Python Add-In Wizard and navigate to the empty folder.
  3. Complete the responses making sure to use new names where the red dots indicate.
  4. When completed, save the changes (this will generate a new AddInID).
  5. Open the Install folders for both your original add-in and the new add-in
  6. In a Python editor copy everything below the "class ClassName(object):"  in your original add-in and paste it below the "class ClassName(object):"  replacing the auto-generated code in your new add-in but keeping the new class name. 
  7. Make the desired changes in the new add-in's Python code and save.
  8. Run the makeaddin.py script.
  9. Double-click on the **.esriaddin file to install the add in.
  10. Use the Add-In Manager as required to complete the process.

It's probably not the simple rename process you were looking for, but it is fairly easy.  Hope this helps.

ChrisHolmes
Occasional Contributor III

Thanks for the detailed info Randy. I’ll give this a shot. Makes sense to create a new empty shell then move everything into it. I’ll update the thread again with my final results. Cheers!

0 Kudos