Select to view content in your preferred language

Arcpy 3.2.2 Polygon getpart issue

441
2
Jump to solution
02-23-2024 08:10 AM
MarceloCesarTorres
New Contributor

I'm trying to get polygon parts  but I get an exception:

File "c:\Users\Mtorres\source\repos\FFP-ArcGISPro-Project\src\Public Inspection\Python Toolboxes\PublicInspectionArcGIS\Centerline.py", line 73, in _extract_parts_from_input_geometry
part = geometry.getPart(index)
File "c:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\arcobjects.py", line 1331, in getPart
return convertArcObjectToPythonObject(self._arc_object.GetPart(*gp_fixargs(args)))
RuntimeError: DescribeGeometry: Error in getting part from geometry

The script runs on ArcGIS Pro v3.2.2. Next script code fragment where I make the call:

        parts = []

        geometry = self.input_geometry
        if geometry.isMultipart :
            part_range = range(0, self.input_geometry.partCount)
        else :
            part_range = range(0, 1)

        for index in part_range :
            part = geometry.getPart(index)
            parts.append(part)

        return parts
 
I run the same code on ArcGIS Pro 3.1but the exception never happens.
 
Is there an error with last version of arcpy?
 
Marcelo
Tags (3)
1 Solution

Accepted Solutions
MarceloCesarTorres
New Contributor

Thanks for your answer, I'm working with a FileGeodatabase. But  I realize that there was a issue with geometries at the feature class: Shape Areas were negatives. 

Capture01.png

Then I used "Repair Geometries" Tool to fix geometries, and everything start to works fine.

Captura02.png

I get this output from tool:

Captura03.png

View solution in original post

0 Kudos
2 Replies
Kepa
by Esri Contributor
Esri Contributor

Hi @MarceloCesarTorres,

I'm not able to reproduce your error in 3.2.2 nor in 3.1.3, at least in my personal environment (FileGDB and PostgreSQL -ST_Geometry). Are you working in an enterprise geodatabase? Shapefiles? In memory?

I'd perform a geometry check just in case and make sure you are working with proper geometries.

Regards,

0 Kudos
MarceloCesarTorres
New Contributor

Thanks for your answer, I'm working with a FileGeodatabase. But  I realize that there was a issue with geometries at the feature class: Shape Areas were negatives. 

Capture01.png

Then I used "Repair Geometries" Tool to fix geometries, and everything start to works fine.

Captura02.png

I get this output from tool:

Captura03.png

0 Kudos