Saya mencoba untuk mengkonversi beberapa skrip python untuk menampilkan tabel (berdasarkan dbf) dari fitur yang terletak di dalam halaman data driven tertentu. Sejauh ini, skrip saya berhasil menyegarkan peta ke tabel tertentu, tetapi skrip tidak memperbarui tabel.
Saya memilikinya mengatur sebagai tiga kotak teks yang harus diperbarui dengan tiga bidang spesifik ketika pengguna menjalankan skrip dari ArcToolbox.
Ada saran mengapa meja saya tidak diperbarui?
import arcpy, sys, os
#Reference current MXD
mxd = arcpy.mapping.MapDocument("current")
#Get input parameter
Name = arcpy.GetParameterAsText(0)
#Reference data frames
mapatlasDF = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
locatorDF = arcpy.mapping.ListDataFrames(mxd, "Locator Map")[0]
#Reference appropriate layers
atlasLyr = arcpy.mapping.ListLayers(mxd, "PinalCreekMapAtlas_HalfMile", mapatlasDF)[0]
locatorLyr = arcpy.mapping.ListLayers(mxd, "Locator Map", locatorDF)[0]
atlasoutlineLyr = arcpy.mapping.ListLayers(mxd, "Map Atlas Outline", locatorDF)[0]
#Reference layout elements by calling ListLayoutElements
for elm in arcpy.mapping.ListLayoutElements(mxd):
if elm.name =="Table1Column1": tab1Col1Txt = elm
if elm.name =="Table1Column2": tab1Col2Txt = elm
if elm.name =="Table1Column3": tab1Col3Txt = elm
#Reference the Data Driven Page object
ddp = mxd.dataDrivenPages
#Set the current page to be the one selected in the script tool
arcpy.AddMessage(Name)
pageID = mxd.dataDrivenPages.getPageIDFromName(str(Name))
mxd.dataDrivenPages.currentPageID = pageID
#Set the appropriate definition queries
atlasLyr.definitionQuery = "Name = '" + Name + "'"
locatorLyr.definitionQuery = "Name = '" + Name + "'"
atlasoutlineLyr.definitionQuery = "Name <> '" + Name + "'"
#Update Sheet Index data frame
arcpy.SelectLayerByAttribute_management(locatorLyr, "NEW_SELECTION", "\"Name\" = '" + Name + "'")
locatorDF.panToExtent(locatorLyr.getSelectedExtent())
#Reference Affected Parcels table and select appropriate records
parcelTable = arcpy.mapping.ListTableViews(mxd, "AffectedParcels")[0]
#Build query and create search cursor to loop through rows
parcelFieldValue = "Page " + Name
queryExp = "\"MapPage\" = '" + parcelFieldValue + "'" #e.g., "MapPage" = 'Page 01'
parcelRows = arcpy.SearchCursor(parcelTable.dataSource, queryExp)
#Clear all table text values
tab1Col1Txt.text = " "; tab1Col2Txt.text = " "; tab1Col3Txt.text = " "
#iteate through each row, update appropiate text
count = 0
for row in parcelRows:
if count < 30: #Table1 - static position
tab1Col1Txt.text = tab1Col1Txt.text + row.getValue("OwnerName") +"\n"
tab1Col2Txt.text = tab1Col2Txt.text + row.getValue("APN") + "\n"
tab1Col3Txt.text = tab1Col3Txt.text + row.getValue("LengthTrail") + "\n"
if count ==30:
arcpy.AddMessage("Table Overflow") #The code could be reworked to show the last 90 records
count = count + 1
arcpy.RefreshActiveView()
arcpy.AddMessage("PROCESS COMPLETED")
ListLayoutElements
tipeTextElement
? Bisakah Anda memperbarui satu nilai teks dalam skrip, tanpa ada kode lainnya?