# Data transfer between Source and python

**URL:** <https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502>\
**Category:** ParaView Support\
**Tags:** python\
**Created:** [February 4, 2020, 10:40am UTC](https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502 "2020-02-04T10:40:39Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)\
**Post date:** [February 11, 2020, 11:12am UTC](https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502/21 "2020-02-11T11:12:25Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![siver](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@siver](https://discourse.paraview.org/u/siver)\
**Post date:** [February 11, 2020, 2:31pm UTC](https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502/22 "2020-02-11T14:31:16Z")

</div>

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:

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

```

c++:

```auto
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

```auto
# 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](https://discourse.paraview.org/u/mwestphal) and [Cory](https://discourse.paraview.org/u/cory.quammen) for all the help!  
Art

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)\
**Post date:** [February 12, 2020, 2:16am UTC](https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502/23 "2020-02-12T02:16:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![siver](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@siver](https://discourse.paraview.org/u/siver)\
**Post date:** [February 12, 2020, 9:16am UTC](https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502/24 "2020-02-12T09:16:07Z")

</div>

Corrected + typos fixed! Thanks again.

[Previous page](https://discourse.paraview.org/t/data-transfer-between-source-and-python/3502.md?page=1)
