Generate a Macro from a State

Hello,

Is there any way that I can generate a Macro from a State file?
Basically I want to repeat the same things that are saved in the state but to another .e file.
So it would be great if I can generate a Macro form the state file. Is there any easy way to do that?

Thanks!

  • Save your state as a python state file by changing the extension when saving the state
  • Edit the beginning of your state file so that, instead of opening a file it applies on the current active source
  • Add it as a macro

Alternatively, you can use the “Tools -> Python Trace” mechanism.

Thank you for your response.

I have created a state file long time ago.

I want to reproduce what I did before, but the state file is already saved. Can I edit this generated file as a Macro or python script ?

is it a .pvsm or a .py state file ?

.pvsm file

Ok, so you can do the following :

  • Open ParaView
  • File -> Load State -> your .pvsm file, Ok
  • File -> Save State -> pythonState.py, Ok
  • Edit -> Reset Session
  • File -> Load State -> pythonState.py, Ok
  • Check everything is allright
  • Edit -> Reset Session
  • Edit your pythonState.py with a text editor
  • remove your reader instanciation and recover the current active source instead
  • Macros -> Add new macros -> pythonState.py, Ok
  • A new macros should have been added
1 Like

Thanks Mathieu - excellent suggestion.

I have noticed over the years that .py state files aren’t as robust as .pvsm files. Please post any issues you have here in Discourse, or even better, on the gitlab bug tracker site.

Thanks, Alan

1 Like

Hi,

I am following this with great interest. But I couldn’t figure out how to do this step:

remove your reader instanciation and recover the current active source instead

Could you please elaborate on this?

Many thanks,

Yi-Min

in the python state file, there is a line like :
reader1 = XMLUnstructuredGridReader("/path/to/your/file")

replace it by :
reader1 = GetActiveSource()

1 Like