In Paraview, one can do Edit -> Reset Session. It brings a clean state.
How can that be done programmatically, from a python script?
I mean it to work for both the GUI (at the python shell and as a macro) and CLI (pvpython
).
PS: I wouldn't know what are the differences between Reset Session and closing / reopening Paraview. I did not test it thoroughly, but in all I could observe, they behave the same.
PS2: I am currently using a contrived way, but it is not quite equivalent to Reset Session.
def reset_session() :
RemoveViewsAndLayouts()
clear_pipeline()
return
def clear_pipeline() :
srcs = GetSources()
for key, val in srcs.items() :
#print( "key = " + str(key) + ", value = " + str(val) )
#print( " (" + str(type(key)) + "), (" + str(type(val)) + ")" )
Delete(val)
del val
return
PS3: I tested an answer with this minimal code, executed from the GUI from Macros -> mymacro, and it crashes.
Disconnect()
Connect()