# How to select one of multiple data sources?

**URL:** https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815
**Category:** ParaView Support
**Tags:** python
**Created:** [March 29, 2021, 9:25am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815 "2021-03-29T09:25:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jone](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jone/32/9307_2.png) [@jone](https://discourse.paraview.org/u/jone)
#### Post date: [March 29, 2021, 9:25am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/1 "2021-03-29T09:25:50Z")

</div>

Hi, experts!  
I tried to use SelectSurfaceCells() to select one of several data sources and found that it was not what I expected. The following code do not get the same source, assuming I selecte the same source:

> selectedRepresentations = vtk.vtkCollection()  
> selectionSources = vtk.vtkCollection()  
> region = [int(x),int(y),int(x),int(y)]  
> self.renderview.SelectSurfaceCells(region,selectedRepresentations, selectionSources)  
> self.source = selectionSources.GetItemAsObject(0)  
> self.source1 = simple.GetActiveSource()

How do you use select to get a data source like source1? I am very confused. Hope to get your help！

---

<div class="post-metadata">

### Author: ![jone](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jone/32/9307_2.png) [@jone](https://discourse.paraview.org/u/jone)
#### Post date: [March 30, 2021, 1:00am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/2 "2021-03-30T01:00:39Z")

</div>

Source is an IDselectionSource. This is different from source1. Is there a way to get source1 directly by selecting it?

---

<div class="post-metadata">

### Author: ![jone](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jone/32/9307_2.png) [@jone](https://discourse.paraview.org/u/jone)
#### Post date: [March 30, 2021, 1:23am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/3 "2021-03-30T01:23:49Z")

</div>

Or can we get the data source through its VTKSMRepresentationProxy?

---

<div class="post-metadata">

### Author: ![jone](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jone/32/9307_2.png) [@jone](https://discourse.paraview.org/u/jone)
#### Post date: [March 30, 2021, 1:49am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/4 "2021-03-30T01:49:41Z")

</div>

Perhaps with a solution, I could take the ID of the VTKSMRepresentationProxy I got and compare it with the VTKSMRepresentationProxy of all the sources, and then get the data source I wanted.  
I don’t know if this isn’t the best solution to the problem, right?

---

<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: [March 30, 2021, 8:21am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/5 "2021-03-30T08:21:35Z")

</div>

Please clarify:

1. What are you trying to do
2. What have you been able to achieve
3. What is not working

---

<div class="post-metadata">

### Author: ![jone](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jone/32/9307_2.png) [@jone](https://discourse.paraview.org/u/jone)
#### Post date: [March 30, 2021, 8:41am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/6 "2021-03-30T08:41:56Z")

</div>

> [@mwestphal](#):
>
> 1. What are you trying to do

I want to use the mouse click location to get one of the multiple data sources in the pipeline, and then do something to the selected data source, such as clip.

> [@](#):
>
> 1. What have you been able to achieve

I’ve used the Pick() method in VTKSMRepresentationProxy to get the representation of the data source(VTKSMRepresentationProxy) I want to select. I get the source by comparing the global ID of the source’s representation with the global ID of all the source’s representations in the pipeline. I think this approach may be one way, may not be the best.

> [@](#):
>
> 1. What is not working

That was my initial question. The source I get from using selectSurfaceCells () is an IdSelectionSource. I don’t think it’s an active source because it can’t be used with filters.

I hope this clarifies my problem.

---

<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: [March 30, 2021, 8:44am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/7 "2021-03-30T08:44:54Z")

</div>

Yes, this is very clear. You are trying to select an active source by clicking on it in the render view.

> I’ve used the Pick() method in VTKSMRepresentationProxy to get the representation of the data source(VTKSMRepresentationProxy) I want to select. I get the source by comparing the global ID of the source’s representation with the global ID of all the source’s representations in the pipeline. I think this approach may be one way, may not be the best.

Correct, but this should work.

> That was my initial question. The source I get from using selectSurfaceCells () is an IdSelectionSource. I don’t think it’s an active source because it can’t be used with filters.

The IDSelectionSource should ave an input, this should be the correct source you are looking for.

---

<div class="post-metadata">

### Author: ![jone](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jone/32/9307_2.png) [@jone](https://discourse.paraview.org/u/jone)
#### Post date: [March 30, 2021, 9:03am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/8 "2021-03-30T09:03:30Z")

</div>

Indeed. But I did not find a way to get the input of the idSelectionSource, so I chose to use Pick().  
Thank you very much for your reply!

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [March 31, 2021, 9:52am UTC](https://discourse.paraview.org/t/how-to-select-one-of-multiple-data-sources/6815/9 "2021-03-31T09:52:59Z")

</div>

> [@jone](#):
>
> Or can we get the data source through its VTKSMRepresentationProxy?

the representation proxy’s “Input” is indeed what you’re looking for. Something like the following should do the trick:

```python
...

smdisplay = selectedRepresentations.GetItemAsObject(0)
display = servermanager._getPyProxy(smdisplay)
source = display.Input

```
