CheckExtension (arcpy)
Récapitulatif
Checks to see if a license is available to be checked out for a specific type of extension.
Once the extension license has been retrieved by the script, tools using that extension can be used. Once a script is finished with an extension's tools, the CheckInExtension function should be used to return the license to the License Manager so other applications can use it. All checked-out extension licenses and set product licenses are returned to the License Manager when a script completes.
Syntaxe
CheckExtension (extension_code)
Paramètre | Explication | Type de données |
extension_code |
Keyword for the extension product that is being checked.
| String |
Type de données | Explication |
String |
There are four possible returned values for CheckExtension:
|
Exemple de code
CheckExtension example
Check for availability of 3D Analyst extension before checking it out.
import arcpy
class LicenseError(Exception):
pass
try:
if arcpy.CheckExtension("3D") == "Available":
arcpy.CheckOutExtension("3D")
else:
# raise a custom exception
raise LicenseError
arcpy.env.workspace = "c:/GrosMorne"
arcpy.HillShade_3d("WesternBrook", "wbrook_hill", 300)
arcpy.Aspect_3d("WesternBrook", "wbrook_aspect")
arcpy.CheckInExtension("3D")
except LicenseError:
print("3D Analyst license is unavailable")
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
Thèmes connexes
4/26/2014