Sunday, 26 May 2019

arcpy - Enumeration Problem with Eclipse and arcgisscripting?


i'm recently using Python for my Processing work that I do with ArcGis 9.3. I figured out, that using Eclipse (with PyDev) could be helpfull for debugging purpose. The geoprocessor is starting as demanded.


Nevertheless i got into trouble using a Example-Script from Esri: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=fieldmappings_properties


fcs = gp.ListFeatureClasses("block*", "Polygon")

for fc in fcs:

This causes an error:


File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 228, in __getitem__
raise TypeError, "This object does not support enumeration"


The Script works fine when starting from ArcCatalog! It seems that the variable "fcs" is of type "instance" and that python ain't able to enumerate this type.


But why doesn't ArcGIS 9.3 have a problem with this? Does anybody know this?



Answer



You can work around this using this idiom:


fcs = gp.ListFeatureClasses("block*", "Polygon")
for fc in iter(fcs.next, None):

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...