Hi all -
I've used ArcHydro quite a bit over the years, done a lot of python geoprocessing too, but this is the first time I've tried to script ArcHydro in python. I just don't seem to be able to run any ArcHydro tools from my python script, there's no explicit error as to why, just a generic script failure. If I do ListToolboxes within the script, ArcHydro is there, if I do ListTools, the ArcHydro tools that I'm calling are there. But when I try to run any of the tools, the script just fails. This is with ArcGIS 10 and ArcHydro 2.0.
Since it looks like Arc already knows about ArcHydro (from being able to list the toolbox and tools), I'd think that I wouldn't need to use ImportToolbox (and would rather not have to, since I'm making a tool to provide to others so don't want to hard-code or ask for paths), but I tried that anyway and the script just hangs on this command:
arcpy.ImportToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Arc Hydro Tools.tbx")
If I don't try to import, the first thing the script was doing is a Flow Direction:
workspace = arcpy.GetParameterAsText(0)
DEM = arcpy.GetParameterAsText(1)
interws = workspace + os.sep + "Intermediate" + os.sep
sshed_gdb = interws + "ssheds.gdb"
flow_dir = interws + "flow_dir"
arcpy.FlowDirection_archydro(DEM, flow_dir)
Maybe it doesn't like the flow_dir setting the whole path, since AH has its own default locations set, so try this:
arcpy.FlowDirection_archydro(DEM, "flow_dir")
Doesn't work. Maybe it doesn't have its own default locations set, so try setting them:
arcpy.SetTargetLocations_archydro("HydroConfig", "Layers", interws, sshed_gdb)
Doesn't work, still no explicit error. Try creating the gdb first, doesn't help. Checked the XML Vector Location Type, it's set to 1 (gdb), Raster to 2 (can't find doc on that, but the RasterLocation is set to a folder by default, so I'm hoping 2 means folder.) All of this works fine using these folders, file names and file types when I run the ArcToolbox tools manually outside of the script.
Put this through a debugger and get this error message:
AttributeError: 'module' object has no attribute 'FlowDirection_archydro'
I must be missing something basic. Any clues as to what are greatly appreciated...
~ Stacie