Data transfer between Source and python

I guess the error name 'UpdatePipelineInformation' is not defined is related.

The information property visibility has only been added recently.
However, UpdatePipelineInformation() work in ParaView 5.7, but it is a source method :
GetActiveSource().UpdatePipelineInformation()

but this doesn’t seem to work for the plugin class itself.

I have no idea what you mean.

I has it! Here is what I ended up with.

Tasks:

  • define dependentParameters = someFunction(parameters) as a transformation of the original parameters, where someFunction is an arbitrary function
  • access them programmatically via python CLI

Requirements:

  • paraview 5.7+

xml:

<DoubleVectorProperty command="GetDependentParameters"
                      information_only="1"
                      name="DependentParameters"
                      panel_visibiliy="default"
                      si_class="vtkSIDataArrayProperty">
</DoubleVectorProperty>

c++:

vtkDoubleArray* myPlugin::GetDependentParameters(){
    // requires: std::vector<double>* parameters; defined elsewhere
    // requires: vtkDoubleArray* dependentParameter; defined elsewhere
    
    dependentParameter->SetNumberOfComponents(1);
    dependentParameter->SetNumberOfTuples(parameters->size());

    for (auto i = 0ul; i < parameters->size(); ++i)
        // myFunction: x -> 2*x, an arbitrary function, defined elsewhere
        dependentParameter->SetTuple1(i, myFunction(parameters->at(i)));

    return dependentParameter;
}

The dependentParameters can now be called from python CLI as

# paraview 5.7
s = GetActiveSource()
s.Parameter = [1, 2, 3]
s.UpdatePipelineInformation()
DependentParameters = [s.SMProxy.GetProperty("DependentParameters").GetElement(i) for i in range(s.SMProxy.GetProperty("DependentParameters").GetNumberOfElements())]
DependentParameters  # > [2, 4, 6]
# paraview 5.8+
s = GetActiveSource()
s.Parameter = [1, 2, 3]
s.UpdatePipelineInformation()
s.DependentParameters  # > [2, 4, 6]

Note: the 5.8+ solutions has not been tested yet.

Big thank you to Mathieu and Cory for all the help!
Art

1 Like

All good, except that UpdatePipelineInformation is still a source method in 5.8.

Corrected + typos fixed! Thanks again.