Using Unique Values Symbology in ArcPy?

المشرف العام

Administrator
طاقم الإدارة
I am using ArcGIS for Desktop 10.1 and Server 10.1 on my machine Windows 7.

I am newbie in python & running simple python script for UniqueValuesSymbology it running fine if I use mxd as “current” but if I update with full mxd path then it’s not updating the layers symbology and did not show any error.

JSFiddle code 1 (using mxd path as current)

import arcpymxd = arcpy.mapping.MapDocument("current")lyr = arcpy.mapping.ListLayers(mxd, "Population")[0]if lyr.symbologyType == "UNIQUE_VALUES": lyr.symbology.valueField = "SUB_REGION" lyr.symbology.addAllValues()arcpy.RefreshActiveView()arcpy.RefreshTOC()del mxdJSFiddle code 2 (using complete mxd path )

import arcpymxd = arcpy.mapping.MapDocument("D:\\ArcGIS_Data\\data\\y1.mxd")lyr = arcpy.mapping.ListLayers(mxd, "Population")[0]if lyr.symbologyType == "UNIQUE_VALUES": lyr.symbology.valueField = "SUB_REGION" lyr.symbology.addAllValues()arcpy.RefreshActiveView()arcpy.RefreshTOC()del mxdI researched on Google, web help and ArcPy syntax for mxd_path still not getting any clue & Python path is perfect in environmental variables

The reason of using mxd path is that I want to make this script automatic using windows scheduler.



أكثر...
 
أعلى