I'm trying to get Geo-HMS "Centroidal Longest Flowpath" to run from within Python.
My current configuration is:
- ArcGIS 10.2.2
- ArcHydro 10.2.0.191
- HEC-GeoHMS 10.2.0.41
- HEC-GeoRAS 10.2.0.12
- HEC-RAS 4.1.0
I've generated a python module using the following code:
import arcpy
import arcpy.toolbox_code
arcpy.toolbox_code.generate_toolbox_module(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Toolboxes\GeoHMS Tools.tbx', r'C:\Program Files (x86)\HEC\HEC-GeoHMS\bin\GeoHMSTools.py' False, False, True)
I then generated a python path file that points to the GeoHMSTools.py module file under the following directory:
C:\Python27\ArcGIS10.2\Lib\site-packages\GeoHMSTools.pth
I'm able to import GeoHMSTools within my Python IDE (Eclipse) as well as within ArcMap Python Interpreter Window and all the tools are visisble. When I try to run Centroidal Longest Flowpath from within Python I receive the following error message after Python crashes:
'''
Created on Feb 2, 2016
@author: PeterW
'''
import arcpy
import GeoHMSTools
subbasin = r"E:\Python\Temp\Model02\Model02.gdb\Layers\Subwatershed"
centroid = r"E:\Python\Temp\Model02\Model02.gdb\Layers\Centroid"
longestflowpath = r"E:\Python\Temp\Model02\Model02.gdb\Layers\LongestFlowPath_2D"
centroidallongestflowpath = r"E:\Python\Temp\Model02\Model02.gdb\Layers\CentroidalLongestFlowPath10"
GeoHMSTools.CentroidalLongestFlowpath(subbasin, centroid, longestflowpath, centroidallongestflowpath)
Unhandled Exception: System.ArgumentException: The object's type must be __ComObject or derived from __ComObject.
Parameter name: o
at System.Runtime.InteropServices.Marshal.ReleaseComObject(Object o)
at ESRI.APWR.HECGeoHMS10.GPCentroidalLongestFlowPath.Finalize()
Any help in being able to resolve the following will be appreciated.