I'm developing some python scripts using the location referencing tools - I found I can include the location referencing tools if I add Program Files (x86)\ArcGIS\LocationReferencing\Desktop10.6\Bin to my python path and import functions from the file locref.py - is this the correct way to use the locating referencing tools in python? The functions are named a little differently in this file than they are when you run them from the toolbox, so I just want to be sure I've got the right tools.
for example if I import this:
from locref import GenerateRoutes
and use GenerateRoutes in a python script, am I correct to assume this is the exact same thing as runnning the generate routes toolbox tool, which results in a function from arcpy.GenerateRoutes_locref?
I can't import GenerateRoutes_locref in my python script, unless it's hiding in another python lib other than the one I found.
I would log a case with Esri technical support for that one. It sounds like there might be a problem with getting the tool imported/accessed before it can even run.
Nathan @ Esri
There's always more than one way to do something in GIS...
I have developed a python scripting "style" where I explicitly import the functions I use from arcpy - rarely do I ever start a script with:
Rather, I would script :
from arcpy import ListFeatureClasses, DeleteField_management, env,
and as I script I would explicitly import each of the functions I need for the script either globally or within a function definition.
It's not right or wrong, It's just how I do it. It's probably be cause I originally learned fortran and they beat "Implicit None" into me... plus importing all of arcpy takes many more milliseconds, and I have things to do other than import all of arcpy all the time.
So, for me, I prefer
from locref import GenerateRoutes, RelocateEvents
as opposed to the method
in order for my method to work however, I need to make sure the locref library in that toolbox location is in my python path for the interpreter environment I am using.
We figured it out. We have both ArcGIS Pro (64bit) and ArcGIS desktop (32bit) installed and it was causing some licensing/library confusion with python and the idle editor. So we installed pyscripter 32bit version and were able to access the licenses and libraries required to run this.
Thanks for the help, Kyle and Nathan. Hopefully this will help others along the way.