How to automate the creation of multiple vtkSMProxy

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

Thanks
Cam

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

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

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.

It’s the center location not the color.

 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?
 }

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

1 Like

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

 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? 
 }

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"));

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.