Script works in python window but not as a tool.

04-05-2022 07:49 AM
New Contributor


I'm trying to run a super simple script to change the band setup of all TIFs loaded in my map.  Runs fine if I paste the code in the python window, but when I add the script to a toolbox and run it, it looks like it's working...I see a lock icon appear next to each TIF, but when it unlocks nothing has updated and it says the geoprocessing tool has successfully run.

Also, is there a way programmatically in python to change just the band setup without having to apply a layer?


import arcpy

m = p.listMaps('Map')[0]
tifs = m.listLayers('*.tif')
sourceLayer = 'C:/source.lyrx'
for tif in tifs:

Thanks for any help!

0 Kudos
1 Reply
MVP Regular Contributor

Hello Sean,

Instead of running the geoprocessing tool against your project, I would point to the actual TIFs and then close the project.  They may be getting locked and unable to update due to being accessed in your project.

Amanda Bishop, GISP