1

I am trying to write a script that sets up a basic Pro project to make sketches for work, but for some reason no matter what I do when I run the script no changes to the projects themselves are happening. I can see where some changes are happening when I rerun later like when I had a print statement for my text elements I could see clones being made but none showed on the map.

If I run the first script inside my template I can at least see the temp layers being made

import arcpy.lr
import tkinter
import arcpy
from tkinter import ttk
from tkinter import messagebox
import os

arnold =  r"C:\Users\DB43952\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\Connection to sqldw.sde\ARNOLD.DBO.ARNOLD"
table = r"C:\Users\DB43952\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\Connection to SQL2.sde\Program_Management.dbo.ProgramsContracts_Mapping"
window = tkinter.Tk()
window.geometry("700x300")
frame = tkinter.LabelFrame(window, text="Sketch Creator", padx=20,pady=10)
frame.pack(pady=10, padx=10, side = "left")
var = tkinter.IntVar(frame)
t = tkinter.StringVar(frame)

def main():
    path = (r"\\san1\GIS\ProgramsContracts\Sketches\\" + t.get())
    if (os.path.exists(path)):
        messagebox.showerror("WARNING", "This job already has a folder present!!!")
    else:
        window.destroy()
        os.mkdir(path)
        arcpy.env.workspace = (r"\\san1\GIS\ProgramsContracts\Sketches\\" + t.get())
        projecttemp = arcpy.mp.ArcGISProject(r"C:\Users\DB43952\Desktop\ArcProTemplates\Template\Teml.aprx")
        print (var.get())
        if (var.get() == 2):
            print ("HI")
            l = arcpy.MakeRouteEventLayer_lr(arnold,"AH_RoadID",table, "AH_RoadID LINE AH_BLM AH_ELM","Line")
            lL = l.getOutput(0)
            llL = arcpy.CopyFeatures_management(lL,"Lines")
            arcpy.MakeFeatureLayer_management(llL,"llL")
            ##arcpy.SelectLayerByAttribute_management("llL","NEW_SELECTION","Job_No = '" + t.get() + "'","INVERT")
            ###arcpy.Delete_management("llL")
            desc = arcpy.Describe(llL)
            mapa = projecttemp.listMaps()[0]
            print (desc.catalogPath)
            Lyt = projecttemp.listLayouts()[0]
            Jobnum = Lyt.listElements("TEXT_ELEMENT")
            for i in Jobnum:
                if (i.name == "Jobnum"):
                    print (i.name, i.text)
                    i.text = "Job" + t.get()
            projecttemp.saveACopy(r"\\san1\GIS\ProgramsContracts\Sketches\\" + t.get() + r"\\" + t.get())
            #Jobnum.text = t.get()


def go(var):
    a = var.get()
    main()

tkinter.Label(frame,text = "Job Number").pack(anchor = "w")
textbox = tkinter.Entry(frame, textvariable = t).pack()

tkinter.Label(frame,text = "Data Type").pack(anchor = "w")
point = tkinter.Radiobutton(frame, text = "Point",variable = var, value = 1).pack(anchor = "w")
line = tkinter.Radiobutton(frame, text = "Line", variable = var, value = 2).pack(anchor = "w")

ttk.Button(frame, text = "Sumbit", command = lambda: go(var)).pack()

window.mainloop()

Second code also trying

import arcpy 
a = arcpy.mp.ArcGISProject("CURRENT")
m = a.listMaps()[0]
l = m.listLayers()
for i in l:
    if (i.name == "shields_arnold"):
        lbl = i.listLabelClasses()[0]
        lbl.expression = "AH_Route"
        lbl.visible = True
        i.showLabels = True
a.saveACopy(r"C:\Users\DB43952\Desktop\ArcProTemplates\TempV2\hi.aprx")

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.