Hello
Every time I execute my python-script in the end it says
Runtime error Traceback (most recent call last): File "<string>", line 52, in <module> File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 7211, in SelectLayerByAttribute raise e ExecuteError: ERROR 000229: Cannot open Rest\Kartenausschnitte A3 mit Aussparung Legende. 1:2500 und 1:3000 Failed to execute (SelectLayerByAttribute). | |
So this is the "bad" part of my script. lyrkartenausschn is "Rest\Kartenausschnitte A3 mit Aussparung Legende. 1:2500 und 1:3000" | |
cursor = arcpy.da.SearchCursor(lyrkartenausschn, [seitenzkartenausschn]) seitenliste = int(19) del seitenliste seitenliste = [] for row in cursor: seitenliste.append(int(row[0])) print seitenliste for seite in seitenliste: for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.name == seitex: elm.text = str(seite) pfdausgabePDFeinzeln = pfadausgpdf[0:-4] +"_"+ str(seite) + ".pdf" #Path arcpy.SelectLayerByAttribute_management (lyrkartenausschn, "NEW_SELECTION", seitenzkartenausschn + " = " + str(seite)) mxd.dataDrivenPages.exportToPDF(pfdausgabePDFeinzeln, "SELECTED") #PDF Export mxd.dataDrivenPages.printPages(druckername, "SELECTED") # Print mxdspeicher = ausgpdfmxd + "\\" + bewirtschafter + ".mxd" mxd.saveACopy(mxdspeicher) del row del cursor del seite del seitenliste del elm arcpy.RefreshActiveView() | |
There's a lot of things I'm doing bevore. So if I leave the "bad" part, it loops trough the whole script perfectly. If I add this part, the error appears.
I also tryed to add the line "arcpy.SelectLayerByAttribute_management (lyrkartenausschn, "CLEAR_SELECTION")" at the verry bottom, but then the same error appears for this line.
So what's wrong with the code? do I have to del something more? or "deactivate" data driven pages? (maybe it's a problem because it's still printing? but then how can I make it wait until it's finished?
thank you for your help!