Now that sounds (reads) much better and cleaner.

Thanks for your time and your response David.

Cheers

On Thu, Mar 2, 2017 at 1:06 PM David E DeMarle <[email protected]>
wrote:

> Use the hidden property called Parameters on the Python Filter/Source to
> pass in information.
>
> >>> prosrc = ProgrammableSource()
>
> >>> prosrc.Script = ("""
>
> ... try:
>
> ...   instring
>
> ... except NameError:
>
> ...   instring = "GOODBYE"
>
> ... print instring
>
> ... """)
>
> >>> prop = prosrc.GetProperty("Parameters")
>
> >>> prop.SetElement(0, "instring")
>
> 1
>
> >>> prop.SetElement(1, "'HELLO'")
>
> 1
>
> >>> prosrc.UpdateProperty("Parameters")
>
> True
>
> >>> prosrc.UpdatePipeline()
>
> HELLO
>
>
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909 <(518)%20881-4909>
>
> On Wed, Mar 1, 2017 at 3:38 PM, Mauro Fontana <[email protected]>
> wrote:
>
> Hello
>
> Sorry to bother, but I can't seem to find a way (in the mailing list or
> the documentation) to pass a string as some kind of argument to
> Programmable Source (using pvpython interpreter). The python "program"
> needs to load a custom binary format using numpy.fromfile.
>
> What I've thought is to write a wrapper function. The function should
> receive a string as argument and then instantiate a programmable filter and
> execute
> myscript.replace(random_var_name, myfilename)
> MyProgrammableSource.Script = myscript
> return MyProgrammableSource
>
> Where random_var_name is the argument of my numpy.fromfile call. But that
> doesn't seem very "pythonic". Is there a way to pass a string to the Script
> without the .replace hack?
>
> Sorry if this is documented, I couldn't find it.
>
> Cheers,
> Mauro
>
> _______________________________________________
> 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
>
>
>
_______________________________________________
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

Reply via email to