<?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 Addin - Extension Checkin Issue in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169884#M555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am unsure about loggin file usage, but you should be able to set up a simple if...else statement to check for availability, peform the nececssary processing and finally check the extension back in.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

### see if spatial analyst extension is available for use
availability = arcpy.CheckExtension("Spatial")
if availability=="Available":
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CheckOutExtension("Spatial")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("SA Extension Checked out")
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("%s extension is not available (%s)"%("Spatial Analyst Extension",availability))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Please ask someone who has it checked out but not using to turn off the extension")
&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&amp;nbsp;&amp;nbsp;&amp;nbsp; #depending upon where this is located, you could also use sys.Exit() or pass/continue

#.... do the necessary processing with the extension
arcpy.CheckInExtension("Spatial")
arcpy.AddMessage("SA Checked back in")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:48:48 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2021-12-11T08:48:48Z</dc:date>
    <item>
      <title>Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169883#M554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: palavido&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello GISers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our organization has a single floating license of 3D Analyst and many times people inadvertently leave it enabled. I was hoping to make a simple Python Add-in that would check the 3D Analyst license in when ArcMap opens. I made a python add-in that executes the code below to check the license in. I set up logging so I could confirm the actions were being taken. The log reports that the license has been successfully checked in, however it still remains checked (enabled) in ArcMap (see screenshot).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV align="center"&gt;[ATTACH=CONFIG]25276[/ATTACH]&lt;BR /&gt;&lt;BR /&gt;My question would be, is there some step in my code that I am missing or is the ChecInkExtension code only related to the scope of code execution and not the ArcMap extension GUI? I've also attached the source files for the python add-in in case anyone wants to compile and test themselves. You'll just need to change the path to the log file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins
import logging

logger = logging.getLogger('myapp')
hdlr = logging.FileHandler(r'd:\Workspace\PythonAddIns\ExtensionChecker\agstest.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)

class ExtensionChecker(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for ExtensionChecker_addin.extcheckerext (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 startup(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.debug( "Fired startup")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stat = arcpy.CheckExtension("3D")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.debug(stat)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stat = arcpy.CheckInExtension("3D")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.debug(stat)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for any help!&lt;BR /&gt;&lt;BR /&gt;Matt&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:48:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169883#M554</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T08:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169884#M555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am unsure about loggin file usage, but you should be able to set up a simple if...else statement to check for availability, peform the nececssary processing and finally check the extension back in.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

### see if spatial analyst extension is available for use
availability = arcpy.CheckExtension("Spatial")
if availability=="Available":
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CheckOutExtension("Spatial")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("SA Extension Checked out")
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("%s extension is not available (%s)"%("Spatial Analyst Extension",availability))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Please ask someone who has it checked out but not using to turn off the extension")
&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&amp;nbsp;&amp;nbsp;&amp;nbsp; #depending upon where this is located, you could also use sys.Exit() or pass/continue

#.... do the necessary processing with the extension
arcpy.CheckInExtension("Spatial")
arcpy.AddMessage("SA Checked back in")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169884#M555</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T08:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169885#M556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: palavido&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply and sample code, however it doesn't solve the particular issue I am having. The issue I am having is that if I already have an extension enabled/checked out in ArcMap, I am trying to get the python code to check that license back in and show it as "unchecked" in the ArcMap extensions dialog (see the screen shot in my previous post). The python code that I wrote (and also the example you provided) executes successfully and says it checks in the extension, however if you open up the extensions dialog in ArcMap, the extension is still checked/enabled.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To recreate this try the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) In ArcMap, manually enable an extension (like Spatial Analyst or 3D Analyst)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Run the python code to check the license in&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Open the extensions dialog (Customize --&amp;gt; Extensions) in ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 14:13:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169885#M556</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-06-17T14:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169886#M557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matt -- I verified the same thing you are experiencing.&amp;nbsp; Ran from a Toolbox script and it did not uncheck th SpatialAnalyst extension in the &lt;/SPAN&gt;&lt;STRONG&gt;Customize--&amp;gt;Extensions&lt;/STRONG&gt;&lt;SPAN&gt; dialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure how to remedy this.&amp;nbsp; Sorry I am not much help on this one!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;j&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 14:42:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169886#M557</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-06-17T14:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169887#M558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: swalbridge&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi James,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply and sample code, however it doesn't solve the particular issue I am having. The issue I am having is that if I already have an extension enabled/checked out in ArcMap, I am trying to get the python code to check that license back in and show it as "unchecked" in the ArcMap extensions dialog (see the screen shot in my previous post).&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As I understand, doing things in &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000z000000"&gt;Python only modifies the arcpy environment&lt;/A&gt;&lt;SPAN&gt;, not the ArcMap environment itself: when you enable an extension in ArcMap, you are in effect checking it out for the duration of that ArcMap session. So, you don't need to manually 'check-in' the license unless folks are leaving ArcMap open and you want 3D analyst at times. One quick hack around this is to leave it disabled, and then use the arcpy approach you outlined to enable it in the code that you do need to use it for, and check it back in. I'm not an expert in this area, but this is my best understanding from reading the documentation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 23:24:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169887#M558</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-06-17T23:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169888#M559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Shaun,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. That's what I kind of figured, but was hoping otherwise. I guess I'll just have to go the VB .NET route for the add-in so I can interact with the ArcMap GUI via ArcObjects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 16:39:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169888#M559</guid>
      <dc:creator>MatthewPalavido</dc:creator>
      <dc:date>2013-06-18T16:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python Addin - Extension Checkin Issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169889#M560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: swalbridge&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you do want to stick with Python, you could probably hack something up using a few ingredients: the list of &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Extensions/0001000000w9000000/"&gt;CLSIDs for extensions&lt;/A&gt;&lt;SPAN&gt;, the spot in the registry those are stored (HKEY_USERS\...\Software\Esri\Desktop10.1\ArcMap\Extensions), and then run an &lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/130763/request-uac-elevation-from-within-a-python-script"&gt;escalated process that updates the registry&lt;/A&gt;&lt;SPAN&gt;. If you already have skill with ArcObjects, that's probably the easiest and safest approach, but I figured I'd mention this for completeness.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 17:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-addin-extension-checkin-issue/m-p/169889#M560</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-06-18T17:42:42Z</dc:date>
    </item>
  </channel>
</rss>

