Select to view content in your preferred language

array.removeAll()

1989
4
03-02-2011 04:56 AM
MichaelFedak
Deactivated User
I have an Array object I would like to clear using array.removeAll() however I keep getting the error:
<type 'exceptions.TypeError'>: unbound method removeAll() must be called with Array instance as first argument (got nothing instead)
Tags (2)
0 Kudos
4 Replies
JasonScheirer
Esri Alum
Could you paste a larger code snippet for context?
0 Kudos
MichaelFedak
Deactivated User
Sorry, here is the code till the line where it fails. I based it on the fourth example here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/DataFrame/00s300000003000000/
import arcpy,os
#Declare Variables
mxd = arcpy.GetParameter(0)
outLocation = arcpy.GetParameterAsText(1)
outName= arcpy.GetParameterAsText(2)+".shp"
outPath = os.path.join(outLocation,outName)
featureList = []
ar=arcpy.Array

#Export the table values to a string
maps=mxd.exportToString()
#Remove field delimiters
maps = maps.replace("'",'').strip()
arcpy.AddMessage(maps)
maplist= maps.split(';')
arcpy.AddMessage(maplist)

#Cycle through list of maps

for mapp in maplist: 
 
 arcpy.AddMessage(mapp)
 mxd1 = arcpy.mapping.MapDocument(mapp)
 
 frames = arcpy.mapping.ListDataFrames(mxd1)
 
 #Cycle through the list
 for df in frames:  
  #Creates a polygon object 
  poly = arcpy.Polygon(ar([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),
         df.spatialReference)         
  featureList.append(poly)
  
  #Remove the array for the next polygon 
  ar.removeAll(ar) 
0 Kudos
JasonScheirer
Esri Alum
You don't need to clear it out each time the way you are, each instance of Array is a stand-alone object:

for df in frames:  
  #Creates a polygon object 
  poly = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),
         df.spatialReference)         
  featureList.append(poly)
                # All done
0 Kudos
MichaelFedak
Deactivated User
Excellent, thank you.
0 Kudos