4 Replies Latest reply on Mar 2, 2011 1:57 PM by mc989538

    array.removeAll()

    mc989538
      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)
        • Re: array.removeAll()
          JScheirer-esristaff
          Could you paste a larger code snippet for context?
          • Re: array.removeAll()
            mc989538
            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) 
            • Re: array.removeAll()
              JScheirer-esristaff
              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
              • Re: array.removeAll()
                mc989538
                Excellent, thank you.