Default representation and color maps for python programmable/algorithm filters?

First time poster here… I am a relatively new user to paraview and vtk, and an intermediate python programmer. I wanted to mention that I in case I start asking some ill posed questions.

I am working on developing a few python algorithm plugins that automate a few common workflows for my team. I have been doing this successfully with programmable filters, and now with the python algorithms loaded as plugins. Very cool stuff!

One question I had was whether I could set default display. I hadn’t work with much of pipeline downstream (actor, mapper) of the objects in the context of python scripting. Is there a way to define these as part of the output of the algorithm or programmable filter?

I realize I may not be asking the right question here, or approaching this the wrong way. In summary, once I produce the new data object with the programmable filter/algorithm I want to set the representation to ‘glyph’ or ‘surface’ and color by a specific variable so as to avoid having to do that manually in the GUI each time it is used. Any advice or tips/tricks are appreciated.

Hinting at which representation to use

To hint that ParaView should select a particular representation for the output of a filter proxy, add a @smhint decorator after the @smproxy.filter decorator. It should look something like

@smproxy.filter(...)
@smhint.xml("""<RepresentationType view="RenderView" type="3D Glyphs" />""")

Coloring by a specific array

To color by a specific variable (and it is a single component data array), set the variable to be the active scalar in your dataset attributes. ParaView should color by it.

For example, try this:

  • Start ParaView
  • Add a Unstructured Cell Types source. It will appear with Surface representation, colored by solid white
  • Now add a Programmable Filter. Before clicking the Apply button, set the Script property to
ipd = inputs[0].PointData.VTKObject
opd = output.PointData.VTKObject
opd.DeepCopy(ipd)
opd.SetActiveScalars('Polynomial')
  • Now click Apply. The result will appear as a Surface representation, but now it is colored by the ‘Polynomial’ array, which is the “active” scalar on the point data (of class vtkPointData) .

This is super helpful and greatly appreciated!

For the @smhint.xml inputs is there any more comprehensive documentation? Or any other strategies for how I can figure out how to configure these without posting a question here every time :slight_smile: ?

For example, I am also trying to orient and scale the 3d glyphs to a specific vector variable to a specific, but have wasted more time than I care to admit going in circles within the documentation. Any help would be appreciated.

Happy to help!

The most thorough documentation of hints so far is located here: https://kitware.github.io/paraview-docs/nightly/cxx/ProxyHints.html

Hope that helps!