Any issues with ms??

523
4
Jump to solution
10-24-2019 09:55 AM
SamanthaGriffore
Occasional Contributor

Hello, I really hope someone can help me. I have been using the same code to export map series for some weeks and today I'm getting an error telling me that my syntax is invalid when exporting ms. 

p = arcpy.mp.ArcGISProject("Current")
l = p.listLayouts()[2]
if not l.mapSeries is None:
ms = l.mapSeries
if ms.enabled:
ms = l.mapSeries
indexLyr = ms.indexLayer
arcpy.SelectLayerByAttribute_management(indexLyr, "NEW_SELECTION", "SA = 19 and AMA = 'A'")
print("Exporting SA{} AMA-{}".format(currentSA, currentAMA)
ms.exportToPDF(relpath + "\P19_MapAtlas_FGD_SA19_AMA-A_SCR.pdf", "SELECTED")
File "<string>", line 12
ms.exportToPDF(relpath + "\P19_MapAtlas_FGD_SA19_AMA-A_SCR.pdf", "SELECTED")
^
SyntaxError: invalid syntax

Why is my ms not valid? I've individually checked that each variable is pointing to the correct feature and I've tested the SelectLayerByAttribute as well, working great. It just does not want to export... Any ideas??

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
SamanthaGriffore
Occasional Contributor

Yes, indeed. The issue was simple syntax it turns out, a parentheses missing on the print statement which made the ms.export function fall within the print function. The error threw off my troubleshooting!

View solution in original post

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

/blogs/dan_patterson/2016/08/14/script-formatting  so there are line numbers and proper formatting.

what is the value of relpath

0 Kudos
SamanthaGriffore
Occasional Contributor

Thank you for the tip on formatting Dan Patterson, I knew there was a better way!
The path is OK, and I got the code to work somehow without modifying anything, I simply had to run each line of code on it's own, slightly painful..... If I figure out what happened I'll post my solution.

Also I should mention I'm running within ArcGIS Pro Python Window.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Samantha Griffore‌ you might want to get a python IDE to use so you don't have to do it line-by-line

/blogs/dan_patterson/2018/12/13/spyder 

0 Kudos
SamanthaGriffore
Occasional Contributor

Yes, indeed. The issue was simple syntax it turns out, a parentheses missing on the print statement which made the ms.export function fall within the print function. The error threw off my troubleshooting!

0 Kudos