Exporting multiple Graphs

565
2
11-08-2012 05:42 AM
cesareolorenzo
New Contributor
Hello everybody,
my colleague and I are trying to save several Graphs contained inside a single *.mxd, but are not capable of doing so iteratively.
On the Esri guide it is written how to point one single Graph and to export it, but how can we automatically save ALL the Graphs inside one project (without having to manually create a list containing hundreds of graph-names)??

This is the Esri script:

Save a graph as a Windows Bitmap image.
# Name: SaveGraph_ExampleBMP.py
# Description: Save a graph as an image

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "c:/temp"

#Set local variables
graph_grf = "us_pop_2003.grf"
outputFile = "outgraph.bmp"
               
#Execute SaveGraph
arcpy.SaveGraph_management(graph_grf, outputFile, "MAINTAIN_ASPECT_RATIO")

Thank you in advance for your advise!

Cesareo Lorenzo
Tags (2)
0 Kudos
2 Replies
ArkadiuszMatoszka
Occasional Contributor II
Hi,
If you have all your graphs in .grf files in one folder you can simply create list of them with os.listdir(path).

import os
path = 'c:\\temp'
grf_list = [file for file in os.listdir(path) if file.split('.')[-1] == 'grf']
for grf in grf_list:
    ...do something...


Regards.
0 Kudos
cesareolorenzo
New Contributor
Thank you for your advice, but the real problem is that we don't have *.grf exports because our graphs are inside the project and not saved in a separated file.
When we tried to export as a *.grf file graphs based upon several fcs that contain a definition query, the graph loses its data origin, so we cannot procede saving graphs as *.grf to sort out things!

We don't understand where these "virtual-inside-the-project" graphs are stored, so we don't know how to write into python the graphs placement so that we can export them iteratively as images.

Does anyone know how to extract these several virtual graphs to a file via python?

Thank you in advance.
0 Kudos