TypeError :Abstract Class

529
3
11-01-2012 08:54 AM
ScottShenberger
New Contributor III
Good Day

I hope I am posting this in the right place. We are having problems with a line of code and we are not sure what is causing the problem. We are running a script that will create data driven pages in pdf form. The line of code that is causing the problem is as follows

  dfAsFeature = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]), df.spatialReference)
  arcpy.SelectLayerByLocation_management(gridLayer, "HAVE_THEIR_CENTER_IN", dfAsFeature, "", "NEW_SELECTION")


The dfAsFeature line always throws the TypeError:AbstractClass error. The odd part is, it works on ArcMap 10.0 but not 10.1. The 10.1 machine is using Python 2.7 while the 10.0 machine is running Python 2.6.

Thank You

Scott Shenberger
Tucson Water
Tags (2)
0 Kudos
3 Replies
RichardDaniels
Occasional Contributor III
I don't know how to fix it, but before Python 2.6.x there was no explicit way to declare an abstract class. It changed with the abc (Abstract Base Class) module now available from the standard library in Python 2.7. I'm getting the same error with this line of code.

partGeom = arcpy.Geometry("polygon", arcpy.Array(trPoints))

The variable partGeom probably needs to be declared now...

Rich
0 Kudos
ChrisSnyder
Regular Contributor III
Scott - Your code executes fine for me in v10.1 SP1 (selection is made correctly). Are you sure that the SR you are trying to assign to your df extent polygon is okay? Is it defined?

I have a layer in ArcMap TOC "County Bounadries", and this code executed correctly:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = mxd.activeDataFrame
polyObj = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]), df.spatialReference)
arcpy.SelectLayerByLocation_management("County Boundaries", "INTERSECT", polyObj)
0 Kudos
ChrisSnyder
Regular Contributor III
Ha - Didn't notice that the OP was almost 2 years old!

Issue was probably fixed with 10.1 SP1 I bet.
0 Kudos