64-bit background geoprocessing & Trace Geometric Network

449
0
11-15-2012 09:52 AM
ErikMartin
Occasional Contributor
I have a Python script that loops through the Trace Geometric Network tool for a set of flags.  I recently installed the 64-bit background geoprocessing which seems to have introduced a problem with the "out_network_layer" parameter.  It appears as though the out_network_layer name can not be overwritten in the background service.  (I am not adding the layer to the active dataframe-- it appears as though it can't be overwritten in the background geoprocessing instance of ArcMap). So, with background geoprocessing turned on this script works on the first iteration, then crashes in subsequent iterations:

import arcpy

Workspace = "C:\\Data\\Test.gdb"
network = "C:\\Data\\Test.gdb\\Hydro\\Hydro"
flags = "flagPoints"
arcpy.env.overwriteOutput = True
arcpy.env.workspace = Workspace

flagUniqIDs = []

fields = ("FLAG_ID")
with arcpy.da.SearchCursor(flags, fields) as rows:
 for row in rows:
  flagUniqID = row[0]
  flagUniqIDs.append(flagUniqID)
  
for flagUniqID in flagUniqIDs:  
 selection = "\"FLAG_ID\" = \'%s\'" %flagUniqID
 arcpy.Select_analysis(flags, "flag", selection)
 flag = "flag"
 
 arcpy.TraceGeometricNetwork_management(network, "netLayerName", flag, "TRACE_DOWNSTREAM")


If I go to the GP results and add the output of the TraceGeometricNetwork tool, the layer group gets added, but it can't find the data (little red exclamation points).

I have devised a workaround that creates a new name for each iteration and it seems to work, but I wonder what's getting cluttered up in the background and slowing things down... especially if there are lots of flags (in some cases, I may have several hundred.)

import arcpy

Workspace = "C:\\Data\\Test.gdb"
network = "C:\\Data\\Test.gdb\\Hydro\\Hydro"
flags = "flagPoints"
arcpy.env.overwriteOutput = True
arcpy.env.workspace = Workspace

flagUniqIDs = []

fields = ("FLAG_ID")
with arcpy.da.SearchCursor(flags, fields) as rows:
 for row in rows:
  flagUniqID = row[0]
  flagUniqIDs.append(flagUniqID)

count = 0  
for flagUniqID in flagUniqIDs:  
 count = count +1
 selection = "\"FLAG_ID\" = \'%s\'" %flagUniqID
 arcpy.Select_analysis(flags, "flag", selection)
 flag = "flag"
 netLayerName = "netLayerName%s" %count
 arcpy.TraceGeometricNetwork_management(network, netLayerName, flag, "TRACE_DOWNSTREAM")

del flagUniqID, flagUniqIDs


If I run the same script with background geoprocessing turned off it works for the whole set of flags.  Prior to the 64-bit GP update, it worked in background geoprocessing for the whole set of flags.

Has anyone else experienced this?  Bug?

Thanks,
-Erik
Tags (2)
0 Kudos
0 Replies