Closed Chaz6 closed 5 years ago
@Chaz6 ,
Although ESRI provides this kind of "convert to Python" code auto-conversion, e.g. also with ModelBuilder toolboxes, the result is rarely directly usable, and you always need to review the resulting code and generally make changes.
This is a known issue, and I guess conversions like this are simply not so straightforward given the rich language Python represents.
Anyway, in your case, I thinks you simply need to add an import toolbox statement as the first line in your code snippet, so before the actual tool call, like you can see in this other thread that does something similar: https://github.com/Esri/arcgis-osm-editor/issues/194
So add this:
arcpy.ImportToolbox(r'c:\program files (x86)\arcgis\desktop10.6\ArcToolbox\Toolboxes\OpenStreetMap Toolbox.tbx'
Just take care of the proper version number of your ArcGIS install to not break the path to the toolbox.
@Chaz6 As @mboeringa mentions, there is an open internal issue for this -- the additional step being the ImportToolbox that currently "Copy as Python Snippet" doesn't correctly auto-generate.
I tried this code
arcpy.OSMGPFileLoader_osmtools(interpreter_osm, "CONSERVE_MEMORY", "", overpass, overpass_osm_pt, overpass_osm_ln, overpass_osm_ply)
and got this error TypeError: OSMGPFileLoader() takes 0 positional arguments but 7 were given
@neogeomat Add the ImportToolbox
command above that @mboeringa mentions -- we have an internal bug for this, but performing the above step is a solid work-around.
@scdub without the ImportToolbox command it gives tool not found an error. I have the imported the toolbox and it is working (checked with arcpy.loadtoolbox). The error is related to #197
I have run the GP tool ""Load OSM File", and used the "Copy as Python Snippet" command, resulting in the following:-
When trying to use this in the Python window, the following error is given:-