|
BLOG
|
Chase - this should be very straight forward (assuming I understand correctly. You can create an update cursor on your feature class and loop through every feature. For every feature you grab the Facility ID then create a search cursor on the related table with a WHERE clause the selects only those related records associated with the current Facility ID - you can even specify a sort order on the search cursor so the related records come back in descending date-order. Take the status field from the first record returned on the search cursor, copy it to the feature record and call updateRow.
... View more
11-09-2021
03:49 PM
|
1
|
0
|
19114
|
|
POST
|
The way I was able change the min and max instances was using the REST API after the publish is complete. I call "https://<services-url>/<folder>/<serviceName.serviceType>" to get the JSON definition of the service, edit the JSON, then call "https://<services-url>/<folder>/<serviceName.serviceType>/edit" to send it back. There is probably an easier way... I'm not sure about the instance type.
... View more
11-09-2021
03:32 PM
|
1
|
2
|
2323
|
|
POST
|
Thanks Dan - indeed there it is right in front of my eyes the whole time. It's tough to understand the reason for this limitation. It sure messes up my automation. I wrote a SQL Server scalar user defined function (eg sde.dons_div(dividend, divisor)) that my views can call when division is needed. That works OK but I've been reading that scalar UDFs can lead to very poor performance on queries of large tables.
... View more
11-04-2021
05:25 AM
|
0
|
0
|
1261
|
|
POST
|
I'm trying to create a database view using the CreateDatabaseView tool. The SQL statement includes a forward slash as a division symbol and it appears to be causing an error. For simplicity let's say "SELECT 5/2 as x". The SQL statement is valid and when I change from division to any other math operator it works. I've tried every trick I can think of to get it accepted but no luck. Any idea? The error from ArcGIS Pro is: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds From Python it is a little more explicit: [[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near '2'.] It appears that the tool is stripping out the division symbol. ArcGIS Pro 2.8.3 SQL Server DB
... View more
11-03-2021
09:36 PM
|
0
|
2
|
1321
|
|
POST
|
It sounds like a database issue to me - what is the underlying database? Our systems use MS SQL Server so I usually test the select statements in the SQL Server Management Studio before using then in arcpy functions such as MakeQueryLayer. Can you so something similar to this?
... View more
10-31-2021
09:56 AM
|
0
|
1
|
847
|
|
POST
|
I've done quite a lot of this and from what you describe it should work with no problem using the python multiprocessing package. The pseudocode below shows the basic flow. As long as each process only touches its own feature class there should be no locking problem. My computer has 8 threads and I usually max it out at 8, there is some odd pleasure in seeing the CPU meters all running at 100%. Throughput increases typically about 5 times what you get with a single processor. Even at 100% I can still use my system to do lightweight interactive work (eg. browsing web sites). import multiprocessing
p = multiprocessing.Pool(<number of processors>)
p.map(<target function>, <list of feature class names>)
p.close()
def <target_function> (feature_class_name):
... your code to process one feature class
return One final note - I HAVE had some problems to get this to work running in a python toolbox, but no problem in a standalone script. And another final note - you need to be careful with naming conflicts if you are creating temporary feature classes as part of the processing. I usually solve this by appending something like the process ID to the name of the temporary object
... View more
10-31-2021
05:29 AM
|
5
|
1
|
3899
|
|
POST
|
Right, I took it out of the loop simply to demonstrate the problem that I have to create a new InsertCursor for every record that I want to insert. I've used InsertCursors before and never had to do that. There seems to be something different about the many to many intermediate table that causes this.
... View more
10-25-2021
11:17 AM
|
0
|
0
|
2330
|
|
POST
|
For the first time I'm trying to set up and use a many to many relationship. The setup went fine, as expected an "intermediate table" is create the contains two GUID fields. My problem is when I try to use ArcPY to populate that table. It seems that I have to create a new InsertCursor for every record that I want to insert. Does that make sense? This code snippet fails on the second insertRow with "Cannot reset foreign key values for an existing relationship row". However when I uncomment out line 12, it works. I guess I can create the insert cursor every time but I expect the table to get very very large and I seen slow cursor creation on large tables, so it may not be practical. import os, arcpy
DB_BASE_PATH = r'C:\Users\dmorrison\Documents\ArcGIS\Projects\CW Development\CW HUB (SDE).sde'
REL_TABLE = os.path.join(DB_BASE_PATH, 'CW_Hub.SDE.TEST_PARCELS_TEST_PARCEL_TO_PARCEL_EVENTS')
P_GUID1 = "31D01E3D-F70B-4382-B841-F9DD552C1859"
P_GUID2 = "AC8D91AC-59FD-4E90-9451-275EEF6A99E9"
E_GUID = "944E481E-4F91-44B3-A640-66383031F8D9"
with arcpy.da.InsertCursor(REL_TABLE, ['parcel_guid', 'event_guid']) as cursor:
cursor.insertRow([P_GUID1, E_GUID])
#with arcpy.da.InsertCursor(REL_TABLE, ['parcel_guid', 'event_guid']) as cursor:
cursor.insertRow([P_GUID2, E_GUID]) ArcGIS Pro 2.8.3 SQL Server 13.0.5888.11 (Windows)
... View more
10-24-2021
05:55 PM
|
3
|
5
|
2740
|
|
POST
|
If you are talking about python modules within a python toolbox and you plan to publish the tool to an ArcGIS server, then my experience is that any custom python modules you import have to be at the same level as the toolbox itself. This has to do with the consolidation that happens during the publishing step, the ESRI code has to find all of the dependent modules and move them to the server. The consolidation code does not look in subdirectories for those dependent modules. If you are not going to be publishing the tool then I don't see any problem importing modules in a subdirectory (not sure if this is what you are asking about).
... View more
10-15-2021
09:55 AM
|
1
|
0
|
6864
|
|
POST
|
Glad to hear it helped. I was thinking that maybe I should have posted a snippet from the execute function where the code sections are conditioned on the associated checkbox being enabled, but it looks like you got the idea OK
... View more
10-15-2021
08:02 AM
|
0
|
0
|
993
|
|
POST
|
I went through this just a couple of days ago and had no problem. I did everything from within ArcGIS Pro Create the clone Make the clone active Restart ArcGIS Pro Add the python package to the cloned install (it does take a while to complete) Once I got it up and verified it worked, I upgraded it using PIP from the DOS command line: pip install --upgrade spyder I have had problems in the past like you describe so it was a big relief when it came up OK. One thing to check is to make sure there are no other spyder processes running when you attempt to start it. It appears that if there is already a spyder process running the startup aborts.
... View more
10-12-2021
02:00 PM
|
0
|
1
|
4755
|
|
POST
|
If I understand what you are trying to do, I usually accomplish it by a displaying set of checkboxes that dictate which input fields to display. The example below might seem like overkill but the code is pretty simple - you just have to set up the mapping of checkboxes to input parameters correctly. def getParameterInfo(self):
cb_0 = arcpy.Parameter(displayName="Checkbox 0", name="cb_0", datatype="GPBoolean", parameterType="Required", direction="Input")
cb_1 = arcpy.Parameter(displayName="Checkbox 1", name="cb_1", datatype="GPBoolean", parameterType="Required", direction="Input")
cb_2 = arcpy.Parameter(displayName="Checkbox 2", name="cb_2", datatype="GPBoolean", parameterType="Required", direction="Input")
in_0 = arcpy.Parameter(displayName="Input 0", name="in_0", datatype="GPString", parameterType="Optional", direction="Input")
in_1 = arcpy.Parameter(displayName="Input 1", name="in_1", datatype="GPString", parameterType="Optional", direction="Input")
in_2 = arcpy.Parameter(displayName="Input 2", name="in_2", datatype="GPString", parameterType="Optional", direction="Input")
in_3 = arcpy.Parameter(displayName="Input 3", name="in_3", datatype="GPString", parameterType="Optional", direction="Input")
in_4 = arcpy.Parameter(displayName="Input 4", name="in_4", datatype="GPString", parameterType="Optional", direction="Input")
return [cb_0, cb_1, cb_2, in_0, in_1, in_2, in_3, in_4]
def updateParameters(self, parameters):
# Parameter indexes
CB_0 = 0
CB_1 = 1
CB_2 = 2
IN_0 = 3
IN_1 = 4
IN_2 = 5
IN_3 = 6
IN_4 = 7
# Map checkbox parameter to visible input parameters
TBL = {CB_0: [IN_0],
CB_1: [IN_1, IN_2],
CB_2: [IN_2, IN_3, IN_4]}
# Update parameter visibility
for p_in in range (IN_0, IN_4 + 1):
parameters[p_in].enabled = False
for p_cb in [p for p in range (CB_0, CB_2+1) if parameters[p].value == True]:
for p_in in TBL[p_cb]:
parameters[p_in].enabled = True
return
... View more
10-11-2021
12:18 PM
|
0
|
3
|
4034
|
|
POST
|
Ah - it's a multivalue parameter - you can read about my struggles here (not related to your problem). When I run into something like this I try to reduce the code down to the absolute bare minimum to reproduce the problem, then start adding print statements so I can see what is going on. For instance, if you remove parameters 1 and 2 can do you still get the error? Also, it would be useful to see the code in your getParametersInfo function.
... View more
10-11-2021
05:42 AM
|
0
|
1
|
4043
|
|
POST
|
So if the parameter value is 'Water', want to remove 'Water' from the parameter's filter list? That won't work. The selected value always has to be a member of the filter list or else you get the ERROR 00800. Or maybe I'm not understanding it right...
... View more
10-08-2021
01:00 PM
|
0
|
1
|
4075
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-18-2025 03:42 PM | |
| 1 | 11-19-2025 02:36 PM | |
| 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 |
11-28-2025
04:52 AM
|