[Paraview] How to set properties of custom vtkSMProxies (python)?
Mario Schreiber
schreibermario40 at gmail.com
Sat Dec 3 12:09:39 EST 2016
Hello,
I'd like to work with custom vtk objects from the ParaView python shell.
Unfortunately, I cannot find in the docs, how to define a property
"MyProperty" in my custom class, that I can access in python using either
myobj.SetMyProperty(<value>) or
myobj.GetProperty("MyProperty").SetElement(0,<value>).
I thought that it was sufficient to have the methods "SetMyProperty" and
"GetMyProperty", in my custom class, which would be wrapped automatically
to create a Property "MyProperty", but it isn't. The class defined below is
wrapped into vtkMyObjectClientServer.cxx during the build process, and it
checks for the method name "Set/GetMyProperty" inside
vtkMyObjectClientServer::vtkMyObjectCommand, but I have no idea how I can
modify these server side property values from the python shell on the
client?
What I have done:
1. define class in vtkMyObject.h:
#ifndef __vtkMyObject_h
#define __vtkMyObject_h
#include "vtkObject.h"
class vtkMyObject : public vtkObject
{
public:
static vtkMyObject *New();
vtkTypeMacro(vtkMyObject,vtkObject);
void PrintSelf(ostream& os, vtkIndent
indent){this->Superclass::PrintSelf(os, indent);}
vtkGetMacro(MyProperty,double);
vtkSetMacro(MyProperty,double);
private:
double MyProperty;
~vtkMyObject(){}
vtkMyObject(){}
};
#endif
2. vtkMyObject.cxx:
#include "vtkMyObject.h"
3. CMakeLists.txt:
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ADD_PARAVIEW_PLUGIN(
Example
"1.0"
SERVER_MANAGER_XML MyConfig.xml
SERVER_MANAGER_SOURCES vtkMyObject.cxx
)
4. MyConfig.xml:
<ServerManagerConfiguration>
<ProxyGroup name="my">
<Proxy name="MyObject" class="vtkMyObject"
label="MyObject">
</Proxy>
</ProxyGroup>
</ServerManagerConfiguration>
5. create plugin using cmake and make and load it in paraview. Then open
the python shell and execute:
myobj=servermanager.CreateProxy("my","MyObject")
print myobj
prop=myobj.GetProperty("MyProperty")
--> myobj is shown as vtkSMProxy, but prop is None.
Can you explain what I have to change, or point my to the relevant
documentation?
Thanks
Mario
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20161203/399d727f/attachment.html>
More information about the ParaView
mailing list