Someone gave me a python toolbox with a GP script tool in it. It works fine in Pro, but I'd like to run it from a command window, outside of Pro. Should this be possible? I can't figure out how to set the parameters that the tool needs. I can easily call other GP tools, like GetCount, etc. I'm running Pro 2.4.3.
Solved! Go to Solution.
The parameters come from entry into the toolbox.
If you open the script that is associated with the toolbox, you could hardcode the parameters into the script ensuring that you match the parameter number with the appropriate parameter. (probably a GetParameterAsText, or GetParameter or even a sys.argv).
You can even provide them at the end of a script and check to see if __main__ is running, and if so, provide the parameters there
if __name__ == "__main__":
"""optional location for parameters"""
script = sys.argv[0]
print("\nRunning... {}\n".format(script))
arg_1 = "something"
arg_2 = "something else"
arg_3 = 3
The parameters come from entry into the toolbox.
If you open the script that is associated with the toolbox, you could hardcode the parameters into the script ensuring that you match the parameter number with the appropriate parameter. (probably a GetParameterAsText, or GetParameter or even a sys.argv).
You can even provide them at the end of a script and check to see if __main__ is running, and if so, provide the parameters there
if __name__ == "__main__":
"""optional location for parameters"""
script = sys.argv[0]
print("\nRunning... {}\n".format(script))
arg_1 = "something"
arg_2 = "something else"
arg_3 = 3