Difference between revisions of "ParaView/Python/SavePipelineAsGraph"
(Created page with "= Summary = The simple API provides functions to manipulate the sources, using graphviz we can save and even show the current Pipeline as a graph, in order to obtain images li...")
Revision as of 10:06, 16 October 2018
The simple API provides functions to manipulate the sources, using graphviz we can save and even show the current Pipeline as a graph, in order to obtain images like this
def SavePipelineGraph(path, format="png", view=False): """Save the state of the pipelines (aka Sources and Filters) as a graph. Specify the path to save the graph to, Optionaly, specify the format to save it to , default "png" and if you want to show it right away, default False. This method is using graphviz and will save two file. One to the graphviz format and another one to the provided format. """ try: import graphviz except ImportError: print("Graphviz could not be imported", file=sys.stderr) return d = graphviz.Digraph() activeSource = GetActiveSource() sources = GetSources() if len(sources) == 0: print("Pipeline is empty") else: for item in sources.items(): key = item source = item color = "red" if source == activeSource else "black" d.node(key, label=key, color=color) proxy = source.SMProxy for i in range(proxy.GetNumberOfProducers()): prod = proxy.GetProducerProxy(i) if prod.IsTypeOf("vtkSMSourceProxy"): d.edge(str(proxy.GetProducerProxy(i).GetGlobalID()), str(key)) d.format = format d.render(path, view=view)