|
POST
|
Thanks Jeff - I'll give that a try in the next couple of days. I've been able to package and share Python toolboxes OK. With the toolboxes, the referenced directory ends up getting installed in the user's Documents\ArcGIS\Packages directory and the paths in the code get fixed up correctly to point there. But now that I'm trying to package the entire project (with the toolbox inside the project) the referenced directory is still ending up in the Documents\ArcGIS\Packages directory as I would expect but the code is altered to point to the Temp directory. I'll see if a relative path works any better and let you know.
... View more
03-17-2020
07:16 AM
|
0
|
0
|
1422
|
|
POST
|
I'm packaging a project with an embedded python toolbox with the intent of sharing it with others via ArcGIS Online. The python tool imports a module and it looks like the path to that module is being incorrectly changed during consolidation. The path to the imported module as I created it is: E:\ROW_as_habitat\temp\test_dir The path after the consolidation(I ran Package Product, uploaded the .ppkx to ArcGIS Online, then open the uploaded .ppkx in ArcGIS Online via the portal) is C:\Users\DMORRI~1\AppData\Local\Temp\ArcGISProTemp1188\..\test_project_1\p20\test_dir I would expect the fixed up path to point into the Packages directory, but this is pointing into the temp directory. I do see the module in what I believe is the proper place in under the Packages directory. In any case the import fails when I run the tool from the packaged project. Here is the tool code as I created it in ArcGIS Pro # -*- coding: utf-8 -*-
import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Toolbox"
self.alias = ""
self.tools = [Tool]
class Tool(object):
def __init__(self):
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
params = None
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
test_dir = r'E:\ROW_as_habitat\temp\test_dir'
arcpy.AddMessage(test_dir)
sys.path.append(test_dir)
import logger as row_logger
arcpy.AddMessage(row_logger.LOG_FILE)
return Here is the code after the fixup # -*- coding: utf-8 -*-
#
# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports
# Esri start of added variables
g_ESRI_variable_1 = os.path.join(arcpy.env.scriptWorkspace,'..\\test_project_1\\p20\\test_dir')
# Esri end of added variables
# -*- coding: utf-8 -*-
import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Toolbox"
self.alias = ""
self.tools = [Tool]
class Tool(object):
def __init__(self):
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
params = None
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
test_dir = g_ESRI_variable_1
arcpy.AddMessage(test_dir)
sys.path.append(test_dir)
import logger as row_logger
arcpy.AddMessage(row_logger.LOG_FILE)
return
... View more
03-15-2020
07:32 PM
|
1
|
5
|
1511
|
|
POST
|
Hi Anna - I did not make any progress on this widget. I ended up creating some python toolbox tools to help users add records and related records to our database. This has turned out to be very difficult and complicated to develop, and not a very nice user interface. Other than than it works great. These tools only run in the ArcGIS Pro client - we would have like to have provided a web interface.
... View more
03-03-2020
01:52 PM
|
0
|
1
|
5170
|
|
POST
|
I've been fighting with a problem where I could not package one of my tools as a geoprocessing package. After lots of trial and error I found that it was connected to a totally innocuous try/except in my code. When the try/except is in the code (see below - for illustration purposes only), the publishing fails with an error message that provides no clue. I noticed at some point that if I highlight the problem tool in the Catalog then click Properties -> Parameters I get this message When I remove the try/except, I can view the properties OK, and more importantly the publish works. I'm not a python expert so maybe there is a good explanation about how a try statement like that could have such a side effect - I'd love to hear it. For my tool I was able to do some recoding and get around the problem. But if you are having trouble with publishing, perhaps a good test is to make sure the tools parameters are viewable via the tool properties. import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Toolbox"
self.alias = ""
self.tools = [TestBoolean]
class TestBoolean(object):
def __init__(self):
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
layer = arcpy.Parameter(displayName="Feature Layer",
name="layer",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
checkbox = arcpy.Parameter(displayName="Checkbox",
name="checkbox",
datatype="GPBoolean",
parameterType="Required",
direction="Input")
checkbox.value = False
params = [layer, checkbox]
for param in params:
try:
filter_list = str(param.filter.list)
except Exception:
filter_list = 'Can not access'
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
return I'm running this on ArcPro 2.4.3 and Python 3.6.8 and Advanced license.
... View more
03-03-2020
11:44 AM
|
0
|
0
|
711
|
|
POST
|
The ESRI team confirmed that this is a bug. The hasBeenValidated attribute is not set correctly when a tool is run from a geoprocessing package. I'm waiting to see if I can get a bug number for tracking. I was actually able to workaround it by saving the parameter values in a global space when exiting updateParameters. Then on the next call to updateParameters I do two things: 1) for those parameters that might change, I compare the incoming parameter value to the saved value to determine if it changed 2) for the filter lists (the user can not change these) I restore the incoming parameter value to the saved value I can explain more if anybody is really interested
... View more
03-01-2020
03:41 PM
|
1
|
0
|
1342
|
|
POST
|
I got it working with Python 3 here are the steps. create aprx file: aprx = arcpy.mp.ArcGISProject(<blank aprx file>) get the map object: m_map = aprx.listMaps()[0] create a table object from the view: table = arcpy.mp.Table(<path to db view>) name the table: table.name = <name I make up> add a where clause: table.definitionQuery = '<where clause>' add the table to the map: m_map.addTable (table) save aprx file: aprx.save() publish the aprx This sequence is actually the same as the code I use to add regular tables (not views) to a map - so it should have been fairly obvious to me. I think the real reason my code kept failing was that my view did not include an OBJECTID column - or perhaps more precisely a column with non-null unique values (at least that is what the documentation says is required of all tables and views). Once I added a non-null unique column column I was able to create and publish the map.
... View more
02-26-2020
04:37 AM
|
0
|
0
|
2212
|
|
POST
|
I got this to work on Python 2.7 by changing step 3 from MakeQueryTable to MakeQueryLayer. Now I'm trying to figure out how to do the equivalent in Python 3/ArcPro. Start with a blank mxd file: mxd_template_obj = arcpy.mapping.MapDocument(blank_template_fn) Get the dataframe: df = ListDataFrames(mxd_template_obj)[0] Create the query layer: arcpy.MakeQueryLayer_management(db_view, table_view_name, ....) Convert it to a TableView object: table_view = arcpy.mapping.TableView(table_view_name) Add it to the map: arcpy.mapping.AddTableView(df, table_view) Save the map: mxd_template_obj.saveACopy(<mxd_file_name>)
... View more
02-25-2020
05:03 AM
|
0
|
0
|
2212
|
|
POST
|
Thanks Dan - I just read through that - fuzzy indeed. This particular tool is being packaged as a "geoprocessing package" - so instead of running on the server, I upload it to ArcGIS Online where users can download it and run it on their ArcPro desktop. It has its own consolidation and validation quirks just like the web tools which run on the server. I've been doing some more digging and I see that geoprocessing package that I build includes both the original code (.pyt and .py files) plus a .tbx file which I believe is a "custom toolbox". It's when I run the tool out of the custom toolbox that the hasBeenValidated setting is never set to True. When I run the tool out of the original code it works OK. Tomorrow I'm attending a 2-day ESRI Midwest User Conference - maybe I can track somebody down that can explain this.
... View more
02-24-2020
07:30 PM
|
0
|
0
|
1342
|
|
POST
|
I went back and checked and hadBeenValidated is never True for any parameter in any of my shared tools. So forget about the speculation that it has something to do with the GPFeatureLayer parameter.
... View more
02-24-2020
05:30 PM
|
0
|
2
|
1342
|
|
POST
|
I've developed a number of python toolbox tools and my latest has a problem that I can't figure out. It works fine when I run it from my ArcPro tool folder, but not when it is run as a shared geoprocessing package downloaded from ArcGIS Online After inserting log statements I see that the root of the problem is that the hasBeenValidated setting on the input parameters is always False for all of the parameters. Nothing I do in the UI results in a True setting. I have 2 parameters that interact based on hasBeenValidated. When parameter A has not been validated, I repopulate the list associated with parameter B and set its value to the first element in the list. But since parameter A always shows up a not validated, it is impossible to make stick any change to parameter B. This is only happening in 2 of my tools - the unique thing about them is that parameter A is a GPFeatureLayer. These are the only 2 tools with that type of parameter. hasBeenValidated is a readonly value so I don't see how anything I do has any control over it but without it I don't see how I can make the tool work correctly. I'm running this on ArcPro 2.4.3 and Python 3.6.8 and Advanced license.
... View more
02-24-2020
06:45 AM
|
0
|
4
|
1445
|
|
POST
|
Update: My tool is designed to work with a web layer as the input - the user goes to the Portal tab and drags an ArcGIS Online REST endpoint onto the contents tab - then drags one of the layers into the input field. I discovered that if I drag a layer whose datasource is the enterprise database server then I can share the trivial tool no problem. So I'm concluding that the problem is using the web layer. Unfortunately I can't easily change my tool to work with the database because then it gets packaged up with tool when I share it which I can't let happen for security reasons.
... View more
02-19-2020
02:24 AM
|
0
|
1
|
2089
|
|
POST
|
I'm going to open a problem ticket on this - I'm opening this here also in case anybody has any good ideas. I added a tool to my python toolbox that has a parameter of type GPFeatureLayer. The tool runs fine from ArcPro. When I try to share it to ArcGIS Online as a geoprocessing package, it fails with this error in the SharingJobLog.log file ERROR 000966: The input layer is not valid ErrorMessage: ERROR 000966: The input layer is not valid I create two trivial tools - The first with a GPString parameter and a GPFeatureLayer parameter, and no other code. The second exactly the same but with the GPFeatureLayer parameter removed. The second one shares OK, but the first on fails with the ERROR 000966. I'm not seeing anything in the documentation that indicates GPFeatureLayer is not supported in a shared geoprocessing package, and I would hope that is not the case since it seems like a pretty basic requirement. Here are the tool definitions I used to test: class PackageTestWithLayer(object): def __init__(self): self.label = "0. Package Test - with layer" self.description = "" self.canRunInBackground = False def getParameterInfo(self): layer_param = arcpy.Parameter(displayName="GPFeatureLayer Input", name="layer", datatype="GPFeatureLayer", parameterType="Optional", direction="Input") string_param = arcpy.Parameter(displayName="Text Input", name="text", datatype="GPString", parameterType="Optional", direction="Input") return [layer_param, string_param] def isLicensed(self): return True def updateParameters(self, parameters): return def updateMessages(self, parameters): return def execute(self, parameters, messages): return class PackageTestWithNoLayer(object): def __init__(self): self.label = "0. Package Test - no layer" self.description = "" self.canRunInBackground = False def getParameterInfo(self): string_param = arcpy.Parameter(displayName="Text Input", name="text", datatype="GPString", parameterType="Optional", direction="Input") return [string_param] def isLicensed(self): return True def updateParameters(self, parameters): return def updateMessages(self, parameters): return def execute(self, parameters, messages): return I'm running this on ArcPro 2.4.3 and Python 3.6.8 and Advanced license.
... View more
02-17-2020
06:13 PM
|
0
|
2
|
2170
|
|
POST
|
I think I tried every combination - although it was quite a while ago when I did this. ESRI acknowledged that there is a bug so I gave up on it.
... View more
02-04-2020
10:40 AM
|
0
|
1
|
2594
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 08-11-2025 09:19 PM | |
| 2 | 08-07-2025 11:47 AM | |
| 1 | 01-18-2022 07:15 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|