"GenerateTransectsAlongLines" License Error when running as part of a script.

798
8
Jump to solution
06-27-2022 09:22 AM
by Anonymous User
Not applicable

I am having an issue with the GenerateTransectsAlongLines command when I try running it through an ArcToolbox script in ArcGIS Pro 2.9.3. The command runs fine at the Python Window command line and also when running manually from the Tools popup. I can run other commands from the Arcpy module via scripting no problem but I get a license error when trying to run this particular command. I have an Advanced license (which shouldn't matter as it's a basic Arcpy command). I also switched back to the default read-only Python Environment in case something might have gone corrupt in the custom environments I setup but no success. Also tried formatting the string parameters as shown below but still no success.

I extracted the relevant code from my script below:

import arcpy

Output_Workspace = arcpy.GetParameterAsText(0)

Output_Vector_GDB_Workspace = arcpy.GetParameterAsText(1)

Input_DEM = arcpy.GetParameterAsText(2)
if Input_DEM == '#' or not Input_DEM:
Input_DEM = "RawLidarDTM" # provide a default value if unspecified

Input_Watercourses = arcpy.GetParameterAsText(3)
if Input_Watercourses == '#' or not Input_Watercourses:
Input_Watercourses = "OHN WC" # provide a default value if unspecified

Input_Waterbodies = arcpy.GetParameterAsText(4)
if Input_Waterbodies == '#' or not Input_Waterbodies:
Input_Waterbodies = "OHN WB" # provide a default value if unspecified

Input_Distance = arcpy.GetParameterAsText(5)
if Input_Distance == '#' or not Input_Distance:
Input_Distance = 100 # provide a default value if unspecified

Input_Length = arcpy.GetParameterAsText(6)
if Input_Length == '#' or not Input_Length:
Input_Length = 400 # provide a default value if unspecified

# Get characteristics
descR = arcpy.Describe(Input_DEM)
descV = arcpy.Describe(Input_Waterbodies)

#Set environment variables
arcpy.env.workspace = Output_Workspace
arcpy.env.outputCoordinateSystem = descV.spatialReference # Input_DEM
arcpy.env.extent = descV.extent
arcpy.env.snapRaster = Input_DEM
arcpy.env.cellSize = str(int(4 * descR.meanCellHeight)) # For half metre lidar, recommended resolution output flattened surface is 2m to create a smoother surface and minimize noise.

# Extract Measure Units
spatial_ref = arcpy.Describe(Input_DEM).spatialReference
mUnit = spatial_ref.linearUnitName
if mUnit == "Meter":
mUnits = "Meters"
else:
if mUnit == "Foot_US":
mUnits = "Feet"
else:
arcpy.AddError("Units can only be Meters or Feet!")
sys.exit()

# Local Variables
WC_Transects = Output_Vector_GDB_Workspace + "\\WC_Transects"
mDistance = str(Input_Distance) + " " + mUnits.lower()
mLength = str(Input_Length) + " " + mUnits.lower()

arcpy.AddMessage("Generating transects along watercourse centrelines..")
arcpy.AddMessage("Units: " + mUnits + " Dist: " + mDistance + " Length: " + mLength)
arcpy.GenerateTransectsAlongLines_management(Input_Watercourses, WC_Transects, mDistance, mLength, "NO_END_POINTS")

Error message is as follows:

Start Time: June 27, 2022 12:08:57 PM
Generating transects along watercourse centrelines..
Units: Meters Dist: 100 meters Length: 400 meters
Traceback (most recent call last):
  File "C:\_Workspace\Projects-2022-23\Elevation\HydroFlattening\CreateTransects.py", line 156, in <module>
    arcpy.GenerateTransectsAlongLines_management(Input_Watercourses, WC_Transects, mDistance, mLength, "NO_END_POINTS")
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 21801, in GenerateTransectsAlongLines
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 21798, in GenerateTransectsAlongLines
    retval = convertArcObjectToPythonObject(gp.GenerateTransectsAlongLines_management(*gp_fixargs((in_features, out_feature_class, interval, transect_length, include_ends), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. 
ERROR 000824: The tool is not licensed. Failed to execute (GenerateTransectsAlongLines).
Failed script (null)...
Failed to execute (CreateTransects).
Failed at June 27, 2022 12:08:58 PM (Elapsed Time: 0.78 seconds)
 
Any thoughts would be appreciated.
Thanks,
John
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Further discussions with Esri Tech Support led to the discovery of a 'bug' when working with the new '.atbx' Toolbox format introduced in version 2.9.x. The new toolbox might be more strict on how tools are programmed (eg. following proper Python language initialization and syntax).  Some of the new commands introduced may not always have the same programming rigor applied to them as the more 'established' commands that have been around for years. But we're not sure as of yet the exact nature of the problem. 

However, there is a work-around... By default, when you create a toolbox in Pro, it will create it only in the new ".atbx" format. But once created, you can convert it back to the previous toolbox format by right-clicking the toolbox and selecting 'Save Toolbox to Version'. Make sure to select "2.8" as the Target Version and ensure your Output Toolbox path is correct before converting. Similarly, any older ".tbx" toolbox can be seen by default in the new versions of Pro (3.0.0 included) and you can keep working with them normally with no issue. Performing this procedure made the Transect Tool functional again.

View solution in original post

8 Replies
MichaelVolz
Esteemed Contributor

Can you change your Pro license from Advanced to Basic to ensure that the tool works within Pro with that license level?

If it does not, you might need to assign a license type in the script itself.

0 Kudos
by Anonymous User
Not applicable

Hi Michael,

I have a Named User License set by our organization admin. I could try and ask them to change it but that would limit me in what I can do with the analysis. I will look into your second suggestion first to see if that is a work-around. If successful, will let you know.

Thanks. 

0 Kudos
MichaelVolz
Esteemed Contributor

Are you running this script on your local machine or on a server through maybe a Windows Scheduled Task that is not your account so that's why the license is not available?

0 Kudos
by Anonymous User
Not applicable

It's being run on my local machine. I tried both my personal Named User Account and a group account we use for posting AGOL content. Both come back negative. I have asked the admin to change my license to basic but that might take a while. I was trying to find an example of doing it in script, but couldn't find any other than in the old desktop ArcGIS environment. 

0 Kudos
by Anonymous User
Not applicable

I now know the problem is not local to my system as I tested the script on our server and also tried out the Concurrent License option and it still doesn't work. I'm curious whether I should be reporting this bug elsewhere. I may provide an update to the topic thread.

0 Kudos
by Anonymous User
Not applicable

Update: The issue still persists. These are the things I have tried.

  • Resetting to the default read-only Python Environment
  • Named User License Basic and Advanced
  • Concurrent License Advanced (with Spatial and 3D Analyst)
  • Tried it out on our server computer to make sure issue is not local to my system.

Even though the transect tool is part of the Arcpy module which only requires a Basic license to run, it is a new tool to ArcGIS Pro which is not available in ArcMap Desktop. Given all this, I believe there is some path glitch associated with the tool since I don't receive any errors with any other commands I tested in the Arcpy module. 

0 Kudos
by Anonymous User
Not applicable

Further discussions with Esri Tech Support led to the discovery of a 'bug' when working with the new '.atbx' Toolbox format introduced in version 2.9.x. The new toolbox might be more strict on how tools are programmed (eg. following proper Python language initialization and syntax).  Some of the new commands introduced may not always have the same programming rigor applied to them as the more 'established' commands that have been around for years. But we're not sure as of yet the exact nature of the problem. 

However, there is a work-around... By default, when you create a toolbox in Pro, it will create it only in the new ".atbx" format. But once created, you can convert it back to the previous toolbox format by right-clicking the toolbox and selecting 'Save Toolbox to Version'. Make sure to select "2.8" as the Target Version and ensure your Output Toolbox path is correct before converting. Similarly, any older ".tbx" toolbox can be seen by default in the new versions of Pro (3.0.0 included) and you can keep working with them normally with no issue. Performing this procedure made the Transect Tool functional again.

TomThompsonEsriCA
Esri Contributor

Further to John's recommendation to downgrade/set the target version to 2.9/2.8 and work with .tbx extensions, we've logged a bug for this issue:

BUG-000150838: In ArcGIS Pro 3.0, the Generate Transects Along Lines tool fails when run from a new .atbx with the error "Tool is not licensed".

 

0 Kudos