visitante

sources of my layers

Discussion created by visitante on Jul 1, 2010
I'm trying to test the code that Ken Gorton proposed in a video but I find an error, I checked but I think this very busy .. anyone could help me
import arcpy
... import arcpy.mapping as map
... import sys,os
... import arcpy.sa as sa
... MXD = map.MapDocument('current')
... New_Path = r' C:\Demo'
... for lyr in map.ListLayers(MXD):
...       if lyr.supports("DATASOURCE"):
...           if lyr.dataSource.count('.gdb')>0:
...                 lyr.dataSource = New_Path + "\\Colombia.gdb\\" + os.path.basename(lyr.dataSource)
... arcpy.RefreshContents()
... arcpy.RefreshGraphics()
... del MXD,lyr
...  
... 
...
Runtime error <type 'exceptions.RuntimeError'>: ERROR 087867: LayerObject: Set attribute dataSource does not exist

Outcomes