我在 ArcMap 10.2 中创建了一个加载项按钮,该按钮将一个浮动的串联动态文本框添加到地图布局中。我的剧本很难过,希望有人能给出答案。
这是我的代码:
def onClick(self):
mxd = arcpy.mapping.MapDocument("CURRENT")
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", " ")[0]:
elmWidth = 4.0
x = 100
elm.text = 'User: <dyn type="user"/> Date: <dyn type="date" format="short"/> <Document Path: dyn type="document" property="path"/>'
elm.fontSize = x
while elm.elementWidth > float(elmWidth):
elm.fontSize = x
x = x-1
arcpy.RefreshActiveView()
del mxd
我收到 UnboundLocalError: local variable 'mxd' referenced before assignment 和 IndexError: list index out of range 的错误我卡住了,需要帮助。
谢谢你。