Select to view content in your preferred language

Setting Target Locations for Archydro with python

2434
4
12-17-2013 08:03 AM
BrendanQuigley
Emerging Contributor
Hi there, i'm sure there is a simple answer but I haven't been able to figure it out yet.

I am trying to script some archydro processing with python. I am using the ArcHydroTools.

I am getting errors about setting the target locations so I put these lines in my code.

RasterLoc = "C:/Users/Me/Documents/Project/ScriptHydro"
VectorLoc = "C:/Users/Me/Documents/progect/ScriptHydro/xArcHydro.gdb"
ArcHydroTools.SetTargetLocations("HydroConfig","Layers",RasterLoc,VectorLoc)


I am getting the following error.

Traceback (most recent call last):
  File "C:\Users\Me\Documents\Project\ScriptMethodPart2.py", line 20, in <module>
    ArcHydroTools.SetTargetLocations("HydroConfig","Layers",RasterLoc,VectorLoc)
  File "C:\Program Files (x86)\ESRI\WaterUtils\ArcHydro\bin\ArcHydroTools.py", line 62, in SetTargetLocations
    raise e
ExecuteError: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
   at ESRI.APWR.ArcHydroGPTools.AHSetTargetLocations.Execute(IArray paramvalues, ITrackCancel trackcancel, IGPEnvironmentManager envMgr, IGPMessages message) in C:\Builds\HydroSolutions\10.1_ArcHydro\Sources\ArcHydroTools\src\ArcHydroGPTools\AHSetTargetLocations.vb:line 434
Failed to execute (SetTargetLocations).


Does anyone know the proper way to set Target locations? I even exported model builder into python but it didn't work because I had to change it to use ArcHydroTools.

Thanks
Tags (2)
4 Replies
ChristineDartiguenave
Esri Contributor
Use "\" instead of "/" in your paths.

Christine Dartiguenave
Esri Water Resources Team
0 Kudos
BrendanQuigley
Emerging Contributor
Does ArcHydro specifically need backslashes?
0 Kudos
ChristineDartiguenave
Esri Contributor
In this case yes. The path is parsed looking for "\".

Christine Dartiguenave
Esri Water Resources Team
0 Kudos
by Anonymous User
Not applicable

Is it still looking for "\" in 2017?

0 Kudos