# How to automate the creation of multiple vtkSMProxy

**URL:** https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122
**Category:** Development
**Created:** [March 5, 2022, 8:37am UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122 "2022-03-05T08:37:25Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Cam](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cam/32/8343_2.png) [@Cam](https://discourse.paraview.org/u/Cam)
#### Post date: [March 5, 2022, 8:37am UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/1 "2022-03-05T08:37:25Z")

</div>

For example, I want to create 100 spheres with different center locations. What is the best way to do this in c++.

Thanks  
Cam

---

<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 7, 2022, 9:06am UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/2 "2022-03-07T09:06:04Z")

</div>

```auto
 for (int i = 0; i < 100; i++)
 {
   pqObjectBuilder::createSource("sources", "Sphere");
 }

```

---

<div class="post-metadata">

### Author: ![Cam](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cam/32/8343_2.png) [@Cam](https://discourse.paraview.org/u/Cam)
#### Post date: [March 7, 2022, 6:44pm UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/3 "2022-03-07T18:44:20Z")

</div>

How do I assign different properties for each pqPipelineSource? For instance, I want to create 100 spheres, each of them having a different center.

---

<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 7, 2022, 7:27pm UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/4 "2022-03-07T19:27:05Z")

</div>

Color is not a property of the source, but of the representation. You first have to create this representation then change the color on it.

---

<div class="post-metadata">

### Author: ![Cam](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cam/32/8343_2.png) [@Cam](https://discourse.paraview.org/u/Cam)
#### Post date: [March 7, 2022, 7:48pm UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/5 "2022-03-07T19:48:28Z")

</div>

It’s the center location not the color.

```auto
 for (int i = 0; i < 100; i++)
 {
   pqPipelineSource* source = pqObjectBuilder::createSource("sources", "Sphere");
   // How to get the properties (i.e., Center, Radius, etc.) from source and change them?
 }

```

---

<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 7, 2022, 7:57pm UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/6 "2022-03-07T19:57:31Z")

</div>

use pqSMAdaptor :  
[https://kitware.github.io/paraview-docs/latest/cxx/classpqSMAdaptor.html](https://kitware.github.io/paraview-docs/latest/cxx/classpqSMAdaptor.html)

---

<div class="post-metadata">

### Author: ![Cam](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cam/32/8343_2.png) [@Cam](https://discourse.paraview.org/u/Cam)
#### Post date: [March 8, 2022, 9:43pm UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/7 "2022-03-08T21:43:14Z")

</div>

Thank you. Another question is how do get the vtkObject from pqPipelineSource?

```auto
 for (int i = 0; i < 100; i++)
 {
   pqPipelineSource* source = pqObjectBuilder::createSource("sources", "Sphere");
   // we already know that source has a underlying object as vtkSphereSource. 
   // How do we get vtkSphereSource from source? 
 }

```

---

<div class="post-metadata">

### Author: ![Cam](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cam/32/8343_2.png) [@Cam](https://discourse.paraview.org/u/Cam)
#### Post date: [March 8, 2022, 10:55pm UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/8 "2022-03-08T22:55:36Z")

</div>

Seems not possible because there is no direct access to vtkObject from client side. But getting the property should be enough for me.  
`vtkSMDoubleVectorProperty* points = vtkSMDoubleVectorProperty::SafeDownCast(source->getProxy()->GetProperty("Points"));`

---

<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 9, 2022, 5:58am UTC](https://discourse.paraview.org/t/how-to-automate-the-creation-of-multiple-vtksmproxy/9122/9 "2022-03-09T05:58:24Z")

</div>

> [@Cam](#):
>
> Seems not possible

It is, using GetClientSideObject(), but this is a builtin only method that you want to avoid using anyway.

Indeed, using SMProp to recover the value of an XML property is the way to go.
