<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic mxd.dataDrivenPages.pageRow.setValue() doesn't work in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/mxd-datadrivenpages-pagerow-setvalue-doesn-t-work/m-p/1414601#M70443</link>
    <description>&lt;P&gt;I'd like to write a Python script to help me deal with making illustrations that are filtered by some number in each layer, and then I want DataDrivenPages to zoom into the corresponding view. However, I have encountered an error as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="微信图片_20240424165535.png" style="width: 745px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101963i86971AE88FDCE757/image-size/large?v=v2&amp;amp;px=999" role="button" title="微信图片_20240424165535.png" alt="微信图片_20240424165535.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have checked the document about 'pageRow', and I knew it was read-only, but it could then be read and/or modified as necessary. But I don't know why this code cannot work.&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import arcpy.mapping as mapping
import xlrd

work_book = xlrd.open_workbook(r'C:\Users\39470\Desktop\schedule.xls')
size = work_book.sheets()[0].nrows
kqbh, kqmc = [], []
for i in range(1, size):
    kqmc.append(work_book.sheets()[0].row(i)[2].value)
    kqbh.append(work_book.sheets()[0].row(i)[3].value)
mxd = mapping.MapDocument('CURRENT')
layers = mapping.ListLayers(mxd)
for number, name in zip(kqbh, kqmc):
    if number != '':
        mxd.dataDrivenPages.pageRow.setValue('KQBH', number)
        for lyr in layers:
            if lyr.isFeatureLayer:
                if lyr.symbologyType == 'UNIQUE_VALUES':
                    sym = lyr.symbology
                    df = mapping.ListDataFrames(mxd)[0]
                    sym.valueField = 'KQBH'
                    sym.classValues = [number]
                    sym.classLabels = [lyr.name]
                    sym.showOtherValues = False
                    arcpy.RefreshActiveView()
                    arcpy.RefreshTOC()
    mxd.saveACopy(r'C:\Users\39470\Desktop\illustrations\\' + name + '.mxd')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Apr 2024 09:51:44 GMT</pubDate>
    <dc:creator>Dazzling</dc:creator>
    <dc:date>2024-04-24T09:51:44Z</dc:date>
    <item>
      <title>mxd.dataDrivenPages.pageRow.setValue() doesn't work</title>
      <link>https://community.esri.com/t5/python-questions/mxd-datadrivenpages-pagerow-setvalue-doesn-t-work/m-p/1414601#M70443</link>
      <description>&lt;P&gt;I'd like to write a Python script to help me deal with making illustrations that are filtered by some number in each layer, and then I want DataDrivenPages to zoom into the corresponding view. However, I have encountered an error as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="微信图片_20240424165535.png" style="width: 745px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101963i86971AE88FDCE757/image-size/large?v=v2&amp;amp;px=999" role="button" title="微信图片_20240424165535.png" alt="微信图片_20240424165535.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have checked the document about 'pageRow', and I knew it was read-only, but it could then be read and/or modified as necessary. But I don't know why this code cannot work.&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import arcpy.mapping as mapping
import xlrd

work_book = xlrd.open_workbook(r'C:\Users\39470\Desktop\schedule.xls')
size = work_book.sheets()[0].nrows
kqbh, kqmc = [], []
for i in range(1, size):
    kqmc.append(work_book.sheets()[0].row(i)[2].value)
    kqbh.append(work_book.sheets()[0].row(i)[3].value)
mxd = mapping.MapDocument('CURRENT')
layers = mapping.ListLayers(mxd)
for number, name in zip(kqbh, kqmc):
    if number != '':
        mxd.dataDrivenPages.pageRow.setValue('KQBH', number)
        for lyr in layers:
            if lyr.isFeatureLayer:
                if lyr.symbologyType == 'UNIQUE_VALUES':
                    sym = lyr.symbology
                    df = mapping.ListDataFrames(mxd)[0]
                    sym.valueField = 'KQBH'
                    sym.classValues = [number]
                    sym.classLabels = [lyr.name]
                    sym.showOtherValues = False
                    arcpy.RefreshActiveView()
                    arcpy.RefreshTOC()
    mxd.saveACopy(r'C:\Users\39470\Desktop\illustrations\\' + name + '.mxd')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 09:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mxd-datadrivenpages-pagerow-setvalue-doesn-t-work/m-p/1414601#M70443</guid>
      <dc:creator>Dazzling</dc:creator>
      <dc:date>2024-04-24T09:51:44Z</dc:date>
    </item>
  </channel>
</rss>

