Solved! Go to Solution.
1>>> SubjectLyr = arcpy.mapping.Layer("Y:\\Notification Radius Pkgs\\Dave3\\Shapefiles\\Dave3Subject.shp") # use either \\ or / in paths 2>>> mxd = arcpy.mapping.MapDocument("CURRENT") 3>>> df = arcpy.mapping.ListDataFrames(mxd, "Radius Map")[0] 4>>> wPath = "Y:\\Notification Radius Pkgs\\" # same as in line 1 5>>> arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE") 6>>> SubjectLyr = arcpy.mapping.ListLayers(mxd, SubjectLyr.name, df)[0] # change reference to layer in mxd 7>>> sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\\LayerFiles\\Subject.lyr") # same as in line 1 8>>> arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)
1>>> SubjectLyr = arcpy.mapping.Layer("Y:\\Notification Radius Pkgs\\Dave3\\Shapefiles\\Dave3Subject.shp") # use either \\ or / in paths
2>>> mxd = arcpy.mapping.MapDocument("CURRENT")
3>>> df = arcpy.mapping.ListDataFrames(mxd, "Radius Map")[0]
4>>> wPath = "Y:\\Notification Radius Pkgs\\" # same as in line 1
5>>> arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE")
6>>> SubjectLyr = arcpy.mapping.ListLayers(mxd, SubjectLyr.name, df) # change reference to layer in mxd
7>>> sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\\LayerFiles\\Subject.lyr")[0] # same as in line 1
8>>> arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)
>>> SubjectLyr = arcpy.mapping.Layer("Y:\\Notification Radius Pkgs\\Dave3\\Shapefiles\\Dave3Subject.shp")
>>> mxd = arcpy.mapping.MapDocument("CURRENT")
>>> df = arcpy.mapping.ListDataFrames(mxd, "Radius Map")[0]
>>> wPath = "Y:\\Notification Radius Pkgs\\"
>>> arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE")
>>> SubjectLyr = arcpy.mapping.ListLayers(mxd, SubjectLyr.name, df)
>>> sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\\LayerFiles\\Subject.lyr")[0]
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'Layer' object does not support indexing
#####Okay - get rid of the index
>>> sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\\LayerFiles\\Subject.lyr")
>>> arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\mapping.py", line 1868, in UpdateLayer
assert isinstance(update_layer, Layer)
AssertionError
>>> arcpy.mapping.Layer(wPath+"Setup10\LayerFiles\Subject.lyr")
<map layer u'Dave502Subject'>
>>> arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\mapping.py", line 1868, in UpdateLayer
assert isinstance(update_layer, Layer)
AssertionError
####What are the values of the variables?
>>> print SubjectLyr
[<map layer u'Dave3Subject'>]
>>> print sourceLayer
Dave502Subject1>>> SubjectLyr = arcpy.mapping.Layer("Y:\\Notification Radius Pkgs\\Dave3\\Shapefiles\\Dave3Subject.shp") # use either \\ or / in paths 2>>> mxd = arcpy.mapping.MapDocument("CURRENT") 3>>> df = arcpy.mapping.ListDataFrames(mxd, "Radius Map")[0] 4>>> wPath = "Y:\\Notification Radius Pkgs\\" # same as in line 1 5>>> arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE") 6>>> SubjectLyr = arcpy.mapping.ListLayers(mxd, SubjectLyr.name, df)[0] # change reference to layer in mxd 7>>> sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\\LayerFiles\\Subject.lyr") # same as in line 1 8>>> arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)
SubjectLyr = arcpy.mapping.Layer("Y:\Notification Radius Pkgs\Dave3\Shapefiles\Dave3Subject.shp")
mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd, "Radius Map")[0]
wPath = "Y:\Notification Radius Pkgs\\"
arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE")
sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\LayerFiles\Subject.lyr")
arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)
SubjectLyr = arcpy.mapping.Layer("Y:\Notification Radius Pkgs\Dave3\Shapefiles\Dave3Subject.shp")
mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd, "Radius Map")[0]
wPath = "Y:\Notification Radius Pkgs\\"
arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE")
sourceLayer = arcpy.mapping.Layer(wPath+"Setup10\LayerFiles\Subject.lyr")
arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)