Use the output of the calculator filter in pvpython

Phil,

There isn’t a direct way to plug a value computed by a Calculator into a property of a filter. Since you are scripting, it is a little bit easier. Python Annotation is actually nice here, because it produces what is expected to be a single string value.

First, you’ll need to update the pipeline up to PythonAnnotation1:

pythonAnnotation1.UpdatePipeline()

Then, you’ll need to fetch the data value from it:

stringValue = FetchData(pythonAnnotation1)[0].GetRowData().GetAbstractArray(0).GetValue(0)

Use GetRowData() because the dataset output of the Python Annotation filter is a vtkTable. Use GetAbstractArray() because a vtkStringArray is an abstract array and not a simple vtkDataArray. Use GetValue(0) to get the one string in the vtkStringArray.

You can convert the string value to float with

float(stringValue)

and plug the result into clip1.Value.

Hope that helps!

3 Likes