How to update values in python paraview?

Hello dear ParaView developers!

I have a filter, and I call from python some functions for it (via command in xml)

Some of filter’s fields are modified

How can I update the value of filter’s field on the client then ?

Thank you very much

I’m not enterely sure to follow your question.

In ParaView, properties are going from the client to the server. Information properties are going from the server to the client. There is not biderectional properties.

If you want to have a client side Qt widget that show multiple property (eg, a standard and a information) than you have to implement it yourself and use panel_widget on a property group.

I hope that answers your question.

But what if function is triggered from the client, e.g. some member function of the filter gets executed, and modifies some fields of the class, which are also properties?

The values of variables, to which some properties correspond, are modified.
How to make the property return have the same value as the variable already has on the server?

I’m afraid I dont follow your question. Could you share an simple XML to illustrate what you want to do ?

I have

		<IntVectorProperty
		   name="X"
		   command="SetX"
		   number_of_elements="1"
		   default_values="0"
		   label="X"
		   panel_visibility="never">
			<Documentation>
				Set X, and trigger Y modification
			</Documentation>
		</IntVectorProperty>

I use it from python:

filter.X = 5              (Python)

And SetX function of my plugin also triggers some code, lets’s say

this->Y = 100;           (C++, triggered by Python)

How can I then get Y from python?

filter.Y   does not work, it has the old  meaning, does not equal to the Y on the server

Y does not exist from pvpython point of view. you could declare it as a information property in the XML though.

It exists

<IntVectorProperty
		   name="Y"
		   command="SetY"
		   number_of_elements="1"
		   default_values="0"
		   label="Y"
		   panel_visibility="never">
			<Documentation>
				SetY
			</Documentation>
		</IntVectorProperty>

But it does not get modified after that what I have described

Indeed, because it is not an information property. property are either standard (client to server) or information (server to client), not bidirectional.

Dear Mathieu, could you give an example how to make this integer property informational one?

https://gitlab.kitware.com/paraview/paraview/-/blob/master/Examples/Plugins/RegistrationName/Plugin/RegistrationName.xml?ref_type=heads#L31

Sadly enough, I dont see this property via python

		<!-- ParaView Mathieu, obtain value from the server -->
		<DoubleVectorProperty
			label="Gettest"
			name="Gettest"
			number_of_elements="1"
			default_values="0"
			command="Gettest"
			panel_visibility="never"
			information_only="1">

		</DoubleVectorProperty>

What do you mean ? What kind of error do you have ?

O, I get it, it is available as filter.test, not as filter.Gettest

Thank you very much!

1 Like

Mathieu, I still have problems

		<!-- Python fpr test -->
		<IntVectorProperty
		   name="Settest"
		   command="Settest"
		   number_of_elements="1"
		   default_values="0"
		   label="Settest"
		   panel_visibility="never">
			<Documentation>
				Python function for test obtaining.
			</Documentation>
		</IntVectorProperty>

		<!-- ParaView Mathieu, obtain value from the server -->
		<DoubleVectorProperty
			label="Gettest"
			name="Gettest"
			number_of_elements="1"
			default_values="0"
			command="Gettest"
			panel_visibility="never"
			information_only="1">

		</DoubleVectorProperty>

However when I do dir(filter) only Settesest is presented, and Gettest is missing, why so?