Select to view content in your preferred language

arcpy.topographic.PolygonToCenterline() not working in geoprocessing tool for ArcGIS Pro

703
4
Jump to solution
06-29-2023 07:28 AM
Labels (1)
OveringUMD
New Contributor II

I got the following error

Traceback (most recent call last):
  File "<string>", line 110, in execute
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\topographic.py", line 1886, in PolygonToCenterline
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\topographic.py", line 1883, in PolygonToCenterline
    retval = convertArcObjectToPythonObject(gp.PolygonToCenterline_topographic(*gp_fixargs((in_features, out_feature_class, connecting_features), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: 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.
Failed to execute (PolygonToCenterline).  " 

when running arcpy.topographic.PolygonToCenterline() in my code. 

Line 110 is:

 

arcpy.topographic.PolygonToCenterline(dissolve_doors, door_lines, None)

 

the whole block of code is:

 

def execute(self, parameters, messages‌‌
"""The source code of the tool."""
door_layer = parameters[0].valueAsText
door = parameters[1].valueAsText
outFC = parameters[2].valueAsText

# memory delete
arcpy.Delete_management("memory")
#output location
arcpy.AddMessage(outFC)
arcpy.AddMessage(door)

#spatial reference
spatial_reference = arcpy.Describe(door_layer).spatialReference

#multi to single
single_doors = 'memory\\single_doors'
arcpy.management.MultipartToSinglepart(door_layer, single_doors)

#buffer
buffer_doors = 'memory\\buffer_doors'
arcpy.analysis.Buffer(single_doors, buffer_doors, "0.1 Feet","FULL","ROUND","NONE",None,"PLANAR")


floor_list =['xxxx']
for item in floor_list:
#select by attribute
floor_id = "FLOOR_ID = '"+ item + "'"
arcpy.AddMessage(floor_id)
door_selection = arcpy.management.SelectLayerByAttribute(buffer_doors, "NEW_SELECTION", floor_id, None)
#dissolve doors
dissolve_doors = 'memory\\dissolve_doors'
arcpy.management.Dissolve(door_selection, dissolve_doors, None, None, "SINGLE_PART", "DISSOLVE_LINES", "")
#polygon to centerline
door_lines = 'memory\\door_lines2'
arcpy.topographic.PolygonToCenterline(dissolve_doors, door_lines, None)

 

The weird thing is, it runs fine step by step in the Python window.
Anyone know if something is wrong with code? Thing this might be a bug @esri
Tags (2)
1 Solution

Accepted Solutions
OveringUMD
New Contributor II

Work Around: 

arcpy.topographic.PolygonToCenterline()

For some reason this geoprocessing tool does not like to be written to memory. When using the code below to create a feature class, it worked fine. 

 # create output feature class
        out_name = os.path.basename(outFC3)
        out_path = os.path.dirname(outFC3)
        arcpy.management.CreateFeatureclass(out_path, out_name, "POLYLINE", None, "DISABLED", "DISABLED", spatial_reference)

Odd that it does not like being written to memory, definitely something Esri should fix.

View solution in original post

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

Code formatting ... the Community Version - Esri Community

will facilitate getting help


... sort of retired...
0 Kudos
OveringUMD
New Contributor II

Work Around: 

arcpy.topographic.PolygonToCenterline()

For some reason this geoprocessing tool does not like to be written to memory. When using the code below to create a feature class, it worked fine. 

 # create output feature class
        out_name = os.path.basename(outFC3)
        out_path = os.path.dirname(outFC3)
        arcpy.management.CreateFeatureclass(out_path, out_name, "POLYLINE", None, "DISABLED", "DISABLED", spatial_reference)

Odd that it does not like being written to memory, definitely something Esri should fix.

0 Kudos
DanHopkins
Esri Contributor

Hi OveringUMD,

I am a Product Engineer on the ArcGIS Production Mapping and ArcGIS Defense Mapping extensions.

Thank you for bringing this issue to our attention. What version of ArcGIS Pro are you using?

I have reproduced your issue and I have logged a bug in our team repository.

Regards,

Dan

0 Kudos
DanHopkins
Esri Contributor

Hi @OveringUMD 

I just wanted to let you know that the issue you identified is addressed for ArcGIS Pro 3.3.

Regards.,

Dan

0 Kudos