<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python Add-In problems in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142562#M11096</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I did 'compile' it into an extension, installed it and did run it in ArcMap 10.1. As I wrote earlier, I'm getting the extension to chose, the toolbar to activate and the button of the tool to click. Also the change of cursor works and drawing the rectangle. It just looks like handing over the extend of the drawn rectangle doesn't work. The method to create the map package as such is simple and I can't see where it should go wrong there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thomas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Mar 2013 21:19:30 GMT</pubDate>
    <dc:creator>TomGeo</dc:creator>
    <dc:date>2013-03-13T21:19:30Z</dc:date>
    <item>
      <title>Python Add-In problems</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142560#M11094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everybody,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was just watching the introduction to Desktop Add-Ins using Python and was trying to create the exact same add-in shown in the video. I can't find any flaws in the code I have written and the Add-In was created and installed without any problem. The toolbar is there and the button with the icon on it as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I click the button the cursor is changing to the cursor type specified in the code and I can draw a rectangle on the map canvas. However, there is nothing shown that the system is busy creating the map package and there is non produced. Needless to say that Outlook does not open a new email...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code to define the function you can find below and it would be nice if you can tell why it does not work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the account of not working... There is an import of module 'pythonaddins' and I get it marked as an unresolved import (that's in Eclipse/PyDev). Also when I use the Python shell, importing that particular module results in 'ImportError: No module named pythonaddins'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers Thomas&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy import pythonaddins&amp;nbsp; class CreateMPKExt(object): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for CreateMapPackage_addin.mpkext (Extension)""" &amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For performance considerations, please remove all unused methods in this class. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True &amp;nbsp;&amp;nbsp;&amp;nbsp; def activeViewChanged(self): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.mapping.MapDocument('Current').activeView == 'PAGE_LAYOUT': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mpktool.enabled = False &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mpktool.enabled = True &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except NameError: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class CreateMPKTool(object): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for CreateMapPackage_addin.mpktool (Tool)""" &amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.shape = "Rectangle" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.cursor = 3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; def onRectangle(self, rectangle_geometry): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; import os, win32com.client &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get reference to current map document and set paths to Document and output package &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument('Current') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdPath = mxd.filePath &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "MXD Path: {0}".format(mxdPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdName = os.path.basename(mxdPath)[0:-4] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdDir = os.path.dirname(mxdPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pkgPath = os.path.join(mxdDir, mxdName + ".mpk") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Package Path {0}".format(pkgPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Check to see if package already exists and delete, then create map package &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.exists(pkgPath): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(pkgPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Succesfully deleted existing package: {0}".format(pkgPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PackageMap_management(mxdPath, pkgPath, extent=rectangle_geometry) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Open new email in Outlook and attach the Map Package &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outlook = win32com.client.Dispatch("Outlook.Application") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email = outlook.CreateItem(0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.Subject = "Map Package Area of Interest" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.Attachments.Add(pkgPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; email.Display()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 17:17:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142560#M11094</guid>
      <dc:creator>TomGeo</dc:creator>
      <dc:date>2013-03-13T17:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In problems</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142561#M11095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you ran this in ArcMap instead of Eclipse and the Python Shell? Also, are you at 10.1?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 17:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142561#M11095</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-13T17:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In problems</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142562#M11096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I did 'compile' it into an extension, installed it and did run it in ArcMap 10.1. As I wrote earlier, I'm getting the extension to chose, the toolbar to activate and the button of the tool to click. Also the change of cursor works and drawing the rectangle. It just looks like handing over the extend of the drawn rectangle doesn't work. The method to create the map package as such is simple and I can't see where it should go wrong there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thomas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 21:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142562#M11096</guid>
      <dc:creator>TomGeo</dc:creator>
      <dc:date>2013-03-13T21:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In problems</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142563#M11097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thomas,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I posted the add-in to arcgis.com if you want to download and compare:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://www.arcgis.com/home/item.html?id=56df83424be54b5aa96aa564b88c10ed" rel="nofollow" target="_blank"&gt;http://www.arcgis.com/home/item.html?id=56df83424be54b5aa96aa564b88c10ed&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code looks alright after a quick look. To debug this what is being printed to the python window? There are a lot of print statements in the code, are any of them being reached? Also win32com is not available by default with a base install of python. You need to actually go out and install it to use it. The pythonaddins module should only be used within ArcGIS Desktop in an add-in.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 22:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142563#M11097</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2013-03-13T22:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In problems</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142564#M11098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the download link and pointing out to look at the Python window! I was aware that win32com is an extra module to install and so I did. What I was not aware of, was the fact that the Python interpreter used is the 32bit and I am normally using arcpy in the 64bit version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Installing the 32bit version helped a great deal and then it was only that the mxd didn't have a description that kept me from succeeding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Works now and I'm looking forward to some nice Python tools! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers Thomas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 06:44:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142564#M11098</guid>
      <dc:creator>TomGeo</dc:creator>
      <dc:date>2013-03-14T06:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In problems</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142565#M11099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am also trying to use Pyton-addin. I have&amp;nbsp; created very simple application to create a toolbox and button under toolbox. it works i can see the my created toolbar in Add-in Manager. however when i tried to create an extension i cannot see my created extension in Customized---&amp;gt; Extension.&amp;nbsp; I have followed the link given in &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000018000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000018000000&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;but i cannot see any extension&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;please adviced.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Apr 2013 15:37:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-problems/m-p/142565#M11099</guid>
      <dc:creator>NadeemQazi</dc:creator>
      <dc:date>2013-04-04T15:37:59Z</dc:date>
    </item>
  </channel>
</rss>

