Mysterious :-)

2381
3
10-05-2015 01:14 AM
JohannesBierer
Occasional Contributor III

Mysterious 🙂

How can it be that this code produces something like multiple recursive printing of the map?

import arcpy
mxd = arcpy.mapping.MapDocument(r"path")
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.mapping.PrintMap(mxd, r"printer", df)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

The DataFrame object is also used as an optional parameter to distinguish printing or export a data frame versus a page layout. For this reason it is important to uniquely name each data frame so a specific data frame can be easily referenced.  From the help

What are your data frame names?  are they all unique

0 Kudos
JohannesBierer
Occasional Contributor III

Now they are two and different?

Layer and NewDataFrame

0 Kudos
DarrenWiens2
MVP Honored Contributor

Can you provide a link to where you found this code snippet, and why you might think this might work recursively?

If you got the code from the PrintMap help page, example two, it says that this only prints the first data frame ([0]). If you want to loop through all data frames, use a for loop and change the df variable.

import arcpy  
mxd = arcpy.mapping.MapDocument(r"path"
dfs = arcpy.mapping.ListDataFrames(mxd)

for df in dfs:
    arcpy.mapping.PrintMap(mxd, r"printer", df)

If this isn't what you're asking, please try rephrasing your question.

0 Kudos