Python. Function CreationRepresentation -> Registering Error ?
I have a library that use the function CreateRepresentation from servermanager
In Paraview 5.6.0, the following minimal example works :
from paraview.simple import *
from paraview.servermanager import *
rv = GetRenderView()
box = sources.Box(registrationGroup="sources", Center=[2., 2., 2.])
display = CreateRepresentation(box, rv, registrationGroup='representations')
display.SetRepresentationType('Surface')
In Paraview 5.10.0, the previous example does not work. I have this message :
File "<string>", line 7, in <module>
File "/home/applis/paraview/5.10.0/lib/python3.9/site-packages/paraview/servermanager.py", line 2332, in CreateRepresentation
setattr(proxy, items[0], items[1])
NameError: name 'items' is not defined
So I corrected the lines 2331 and 2332 of servermanager.py from
for param in extraArgs.items():
setattr(proxy, items[0], items[1])
to
for param in extraArgs.items():
setattr(proxy, param[0], param[1])
Then when I run the minimal example, I have the following message:
Traceback (most recent call last):
File "<string>", line 7, in <module>
File "/home/applis/paraview/5.10.0/lib/python3.9/site-packages/paraview/servermanager.py", line 2332, in CreateRepresentation
setattr(proxy, param[0], param[1])
File "/home/applis/paraview/5.10.0/lib/python3.9/site-packages/paraview/servermanager.py", line 489, in __setattr__
raise AttributeError("Attribute %s does not exist. " % name +
AttributeError: Attribute registrationGroup does not exist. This class does not allow addition of new attributes to avoid mistakes due to typos. Use add_attribute() if you really want to add this attribute.
The proxy does not seem to have the attribute registrationGroup
. In the documentation of the function, it seems possible to use this attribute :
def CreateRepresentation(aProxy, view, **extraArgs):
"""Creates a representation for the proxy and adds it to the render
module.
This method can also be used to initialize properties by passing
keyword arguments where the key is the name of the property.In addition
registrationGroup and registrationName (optional) can be specified (as
keyword arguments) to automatically register the proxy with the proxy
manager.
This method tries to create the best possible representation for the given
proxy in the given view. Additionally, the user can specify proxyName
(optional) to create a representation of a particular type."""
global rendering
if not aProxy:
raise RuntimeError ("proxy argument cannot be None.")
if not view:
raise RuntimeError ("view argument cannot be None.")
if "proxyName" in extraArgs:
display = CreateProxy("representations", extraArgs['proxyName'], None)
del extraArgs['proxyName']
else:
display = view.SMProxy.CreateDefaultRepresentation(aProxy.SMProxy, 0)
if display:
display.UnRegister(None)
if not display:
return None
proxy = _getPyProxy(display)
proxy.Input = aProxy
for param in extraArgs.items():
setattr(proxy, param[0], param[1])
proxy.UpdateVTKObjects()
view.Representations.append(proxy)
return proxy
When I delete the 'registrationGroup' keyword when I called the function CreateRepresentation in the minimal example, it is okay but I have the following message when I exit Paraview (this message appears only when I called the function CreateRepresentation) :
# Loguru caught a signal: SIGABRT
# Stack trace:
# 8 0x152dc69dc073 /home/applis/paraview/5.10.0/bin/../lib/../lib/libvtkIOGeometry-pv5.10.so.1(+0x38073) [0x152dc69dc073]
# 7 0x152deabb6037 __cxa_finalize + 247
# 6 0x152dea774136 std::vector<std::string>::~vector() + 198
# 5 0x152deabfeeec /lib64/libc.so.6(+0x82eec) [0x152deabfeeec]
# 4 0x152deabfd5ec /lib64/libc.so.6(+0x815ec) [0x152deabfd5ec]
# 3 0x152deabf64e7 /lib64/libc.so.6(+0x7a4e7) [0x152deabf64e7]
# 2 0x152deab9ddb5 abort + 295
# 1 0x152deabb337f gsignal + 271
# 0 0x152deabb3400 /lib64/libc.so.6(+0x37400) [0x152deabb3400]
# ( 317.581s) [paraview ] :0 FATL| Signal: SIGABRT
I think that when the Representation is created, it is not corectly registered which explains this SIGABRT signal. Is someone have an idea of the way that I can correct it ?
Best regards
Camille