Problem importing Arc Hydro toolbox for a stand alone script

363
1
08-19-2021 02:27 PM
C__JustinMayers
New Contributor

I'm trying to use ArcGIS Pro's Arc Hydro toolbox in a stand alone script. I'm having difficulty importing the toolbox even when sitting in ArcGIS Pro's Python window. I'm running ArcGIS Pro 2.8.1 and I have tried both the 2.8.1 and 2.8.6 versions of ArcHydro. I can run tools from the Arc Hydro tool box in ArcGIS Pro but I need to automate my process using a script.

C__JustinMayers_0-1629408275129.png

The error thrown suggests that code in the tool box has an extra quotation mark. I can't imagine it's that simple and even if it is, I'm not sure how to edit this toolbox. Any thoughts?

 

0 Kudos
1 Reply
C__JustinMayers
New Contributor

I think I found a work around. Instead of importing the tool box and using that path to the tool I have a more direct path to the tools that I need. I imported the script file directly and follow the logic in the code block under "if(__name__=='__main__'):" and that seems to work. I'll have to confirm that it works for the other operations that I need to do.

Are there any problems moving forward in this manner?
 
import drainagelineprocessing as d
oProcessor = d.DrainageLineProcessing()
oProcessor.bCallFromPYT = False
params = (r"H:\workspace\streamstats\02_post_editor\1501\15010005\strlnk", r"H:\workspace\streamstats\02_post_editor\1501\15010005\hydrodem_data.gdb\fdr", r"H:\workspace\streamstats\02_post_editor\1501\15010005\hydrodem_data.gdb\D3test", r"H:\workspace\streamstats\02_post_editor\1501\15010005\hydrodem_data.gdb\D3test_tbl")
tResults = None
tResults = oProcessor.execute(params, None)
0 Kudos