Via a Python toolbox I am calling arcpy.CreateGraph_management('default.tee', graphobj, 'temp'), where graphobj is a graph object created using the arcpy.Graph() class.
When I execute my tool, the create graph call is made without error, but a graph is never displayed. Additionally, the graph does not appear in the Graph Manager. Oddly, when I start to type the CreateGraph command into the command prompt, I see that 'temp' is available as a '.grf' file to fulfill the first argument.
The CreateGraph documentation suggests that the graph needs to be added to the 'host application', but does not provide any guidance. How can a PythonToolbox create a graph and then display it?
Dan,
This is running via a Python Toolbox in an instance of ArcMap. So, ArcMap is open. The existing graph, as per the documentation, can be an arcpy.Graph() object, which it is. When running MakeGraph_management as a stand alone tool, via the Data Management toolbox, a new graph window is render. When running the same tool within a PythonToolBox, a window is not rendered. Given this, I am not seeing the expected behavior.
I concur with all the answers that suggest that ArcMap is the host application. The issue is that, via a Python Toolbox, MakeGraph_management is NOT opening a graph window.
Can anyone else confirm this behavior in a running ArcMap instance using a PythonToolBox.
Thanks,
Jay
I've been having the same issue. This is what worked for me to add the graph to display...
arcpy.env.addOutputsToMap = True
arcpy.MakeGraph_management(graph_grf, graph, outgraphname)
arcpy.env.addOutputsToMap = False