脚本文件 render.py
import arcpy
def renderbatch(rlayer):
rtype = None
if rlayer.isFeatureLayer:
rtype = 0
elif rlayer.isRasterLayer:
rtype = 1
else:
arcpy.AddMessage("Reference Layer can only be feature layer or raster layer!")
return
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = arcpy.mapping.ListLayers(mxd, data_frame=df)
for layer in layers:
stype = None
if layer.isFeatureLayer:
stype = 0
elif layer.isRasterLayer:
stype = 1
else:
continue
if stype == rtype:
arcpy.mapping.UpdateLayer(df, layer, rlayer, True)
pass
rLayer = arcpy.GetParameter(0)
renderbatch(rLayer)
arcpy.AddMessage("finished!")
在Arcgis中添加该脚本
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/39a028640b3860edc978930b467619f6.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f1dcd32c7d9b6f15d09134b7d3cb77b3.png)