How to check whether SpatialAnalyst extension is enabled using SDK?

626
6
04-22-2020 03:18 AM
Sai_PhaneendraPoludasu2
New Contributor III

I do see this Pro SDK snippet which looks for the availability of extension to checkout and check-in. Is there a way to just check whether the extension is licensed/enabled or not ?

Tags (1)
0 Kudos
6 Replies
DanPatterson_Retired
MVP Esteemed Contributor

If an extension is licensed for you, it is available for you

CheckOutExtension—ArcPy Functions | Documentation 

Use extensions—ArcGIS Pro | Documentation 

 If your organization has purchased extension licenses, and a license has been assigned to you, the tools and functionality associated with the extension are available automatically.

Unlike arcmap where you have to enable/disable and extension

0 Kudos
Sai_PhaneendraPoludasu2
New Contributor III

May be my question was not so clear, I would like to validate whether the tool is licensed/assigned and show user a message that the tool requires an extension rather than showing an error halfway through the execution where the extension comes into picture and throws an error cannot run the tool without license.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor
import arcpy

checks = ['3D', 'Spatial', 'ImageAnalyst']

for c in checks:
    print("{} ... {}".format(c, arcpy.CheckExtension(c)))
    
3D ... Available
Spatial ... Available
ImageAnalyst ... Available

CheckExtension—ArcPy Functions | Documentation  perhaps

0 Kudos
Sai_PhaneendraPoludasu2
New Contributor III

Thanks for your response. I could not find a C# SDK alternative for CheckExtension method.

0 Kudos
CharlesMacleod
Esri Regular Contributor
0 Kudos
Sai_PhaneendraPoludasu2
New Contributor III

Thanks Charles, I have tried IsAvailable method already and it does return true even after the "Licensed" checkbox is turned off using "Configure your Licensing Options" from Licensing tab.