Enabling data driven pages in a script

4034
5
07-19-2011 01:55 PM
AJJwair
New Contributor
Hello everybody,

I am trying to enable data driven pages using a python script. It is as simple as it sounds, I cannot figure out a way to do it. I do not want to manually use the data driven pages toolbar AT ALL. Lets say I'm making a tool, I do not have manual access to every map the tool will run on.

Assume I have everything, take a very simple example, I have a map (mxd) and it has one data frame and one layer. I created a (grid) using:
arcpy.GridIndexFeatures_cartography
and added it to the map as a layer.

Is there a way to programatically check that (enable data driven pages) checkbox ! and set the fields in (setup data driven pages)

My 'Layer' in this case will be 'grid'..

I know it is possible because according to ESRI:
"Map series can be created without any scripting at all by using the Data Driven Pages toolbar from within ArcMap. The reverse is also true: map series can be completely scripted using arcpy.mapping without using the Data Driven Pages user interface in ArcMap"

Could you please help me with that

Thank you very much in advance,
AJ
Tags (2)
0 Kudos
5 Replies
KimOllivier
Occasional Contributor III
I understand that  data driven pages have to be set first in the MXD, there is no function in Arcpy.
You will have to think of a workaround.

eg Have a template MXD with DDP enabled, presumably with a suitable layer for the pages. Then copy the layers from the "unabled MXD" and you can then plot the pages.

or if you have access to an ArcObjects wizard, use the comptypes module to enable DDP with the required ArcObjects calls.
0 Kudos
AdhimoolamD
New Contributor
Hi  AJ,
I my case, to display multiple dataframe (map) on each pages in DDP? I hope i can do this if it PY script support to setting/enabling the DDP.

kinly let me know if you find any Solution to setting/enabling the DDP by PY script?

AD.
0 Kudos
ChrisFox3
Occasional Contributor III
Kim is correct, it is not possible to enable Data Driven Pages through arcpy. In addition, it is not possible author or enable Data Driven Pages through the ArcObjects API either. This can only be done in ArcMap via the Data Driven Pages toolbar.
0 Kudos
AJJwair
New Contributor
Thank you for your replays

Kim, I guess that what I will do, have a blank map with DDP enabled somewhere, and let the user browse for it.

Chris, Do you know if there's a reason for that? It seems to me like a lot of people try make their tools to output visually, and since ESRI encourages people to make tools, how come they don't give the developers the full potential of DDP in arcpy?
0 Kudos
AdhimoolamD
New Contributor
Hi,

I have done what i expected, that is.. I have multiple Data frame in my MXD and DDP applied one of the Data frame. When the user clicks the page navigation button in the DDP toolbar, system automatically change the extent and rotation angle for he rest of all Data frame along with the DDP enabled data frame.

To achieve this in Arcobject - by OnActiveViewEventsAfterDraw even. here i have hot coded the Data frame name which has used to enable DDP.

But i needs to find dynamically which Data frame has been used to DDP enable. Let me know How can I do this?

Reagrd
AD.
0 Kudos