Python code works in Python Window within Pro, but not in Toolbox

03-22-2023 11:34 PM
Labels (1)
New Contributor



I have a problem when running a Python code from a toolbox. The purpose of my code is to apply definition queries to layers in an ArcGIS Pro projec (aprx), then zoom to the a specific extent using:


The code works fine when I use the python window within ArcGIS Pro and set the ArcGIS Project to "CURRENT":

aprx ='CURRENT')


However, it does not work when I move the code to a toolbox and run it. Of course I change the ArcGIS Project from "CURRENT" to the exact Path of the aprx file.


Your help is greatly appreciated!



Tags (4)
0 Kudos
2 Replies
MVP Esteemed Contributor

Camera—ArcGIS Pro | Documentation

It is a derived property as indicated in the help topic.  Your code snippet uses the absolute path as indicated, but you dont seem to use saveACopy as in the help topics.  Perhaps when absolute paths are used, the extent changes aren't persisted until the project is saved

... sort of retired...
Esteemed Contributor

Can you supply the rest of your code to help troubleshoot the issue?

0 Kudos