[Paraview] Use of Python declared variables inside new scripts from ProgrammableSource and/or ProgrammableFilter.

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Mon Jan 4 14:22:22 EST 2016


The following works in builtin (non-remote server) mode only.

global meta_data
meta_data =12

p = ProgrammableSource()
p.Script="""
global meta_data
print meta_data
"""

UpdatePipeline()

--------------------------------------------
Output:
--------------------------------------------
12

Utkarsh

On Wed, Dec 30, 2015 at 9:03 AM, Guillaume Jacquenot
<guillaume.jacquenot at gmail.com> wrote:
> I would like to use Python declared variables inside new scripts from
> ProgrammableSource and/or ProgrammableFilter.
>
> Why do I want such a thing? I could simply declared these variables in the
> code of the script.
> But what if these variables are to be used by several scripts from
> ProgrammableSource and/or ProgrammableFilter?
>
> Of course, I can serialize variables and pass the serialized data to the
> scripts, taking special care for float. But, what if I have large data, that
> are difficult to serialize?
>
> So, here is my question:
> Is there a mechanism to access already defined data inside the scripts of
> ProgrammableSource and/or ProgrammableFilter? For example, a global scope
> dict?
> Do I have to use an external file to store and access data?
> Below is the example of the Python file I would like to run , where I have
> defined a 'data' that I want to access inside the script. If I try to
> directly access 'data', I have a "NameError: global name 'data' is not
> defined"
>
> My data are in fact transformation matrices that will be used to move
> objects from a ProgrammableFilter. Using the Animation Keyframes are
> terribly slow.
>
> Guillaume
>
>
>
> Python script:
>
>     data = ....
>
>     script="""
>     instructions to access "data" at run time
>     ...
>     """
>
>     scriptRequestInformation="""
>     ...
>     """
>
>     source = ProgrammableSource()
>     source.OutputDataSetType = 'vtkStructuredGrid'
>     source.Script = script
>     source.ScriptRequestInformation = scriptRequestInformation
>     source.PythonPath = ''
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>


More information about the ParaView mailing list