[Paraview] Use of Python declared variables inside new scripts from ProgrammableSource and/or ProgrammableFilter.
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Sat Jan 23 11:30:05 EST 2016
> However this solution does not work for ProgrammableSource
> from paraview.simple import ProgrammableSource
> p=ProgrammableSource()
> p.Script = 'print(self.x)'
> p.RequestInformationScript = 'if "x" not in dir(self):\n self.x=12'
> UpdatePipeline()
> AttributeError: Attribute RequestInformationScript 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 error message is not complaining about "self.x = 12", it's
complaining about p. RequestInformationScript.
RequestInformationScript is not the right name. Use
p.ScriptRequestInformation instead. The following works for me:
p = ProgrammableSource()
p.Script = "print(self.x)"
p.ScriptRequestInformation = 'if not hasattr(self, "x"): self.x = 12'
UpdatePipeline()
More information about the ParaView
mailing list