import arcpy import pythonaddins import os import datetime import time arcpy.env.overwriteOutput = True class GraphicElementClass(object): """Implementation for GraphicElement_addin.button (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd, "LineTableLayoutz")[0] tableText = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "TableText")[0] numRows = int(arcpy.GetCount_management(lyr).getOutput(0)) rowHeight = 0.2 fieldNames = ["Sequence", "ParcelPlot_No", "FromBeaconNo", "ToBeaconNo", "Bearing", "Length"] numColumns = len(fieldNames) colWidth = 1.5 if df.scale <= 250: upperX = 2.5 upperY = 7.0 elif df.scale <= 500: upperX = 2.5 upperY = 7.0 elif df.scale <= 750: upperX = 2.5 upperY = 8.0 elif df.scale <= 1000: upperX = 2.5 upperY = 8.0 elif df.scale <= 1500: upperX = 2.5 upperY = 8.0 elif df.scale <= 2000: upperX = 2.5 upperY = 8.0 elif df.scale <= 2500: upperX = 2.5 upperY = 8.0 elif df.scale <= 5000: upperX = 2.5 upperY = 8.0 else: if df.scale <= 10000: upperX = 2.5 upperY = 8.0 tableText.elementPositionX = upperX + 0.05 tableText.elementPositionY = upperY tableText.text = fieldNames[0] accumWidth = colWidth for field in range(1, numColumns): newFieldTxt = tableText.clone("_clone") newFieldTxt.text = fieldNames[field] newFieldTxt.elementPositionX = newFieldTxt.elementPositionX + accumWidth accumWidth = accumWidth + colWidth table = arcpy.SearchCursor(lyr.dataSource) y = upperY - rowHeight for row in table: x = upperX + 0.05 try: for field in fieldNames: newCellTxt = tableText.clone("_clone") newCellTxt.text = row.getValue(field) newCellTxt.elementPositionX = x newCellTxt.elementPositionY = y accumWidth = accumWidth + colWidth x = x + colWidth y = y - rowHeight except: print"Invalid value assignment"
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.