[Paraview-developers] How to use the "Parameters" property of "Programmable Filter" in pvpython?
David E DeMarle
dave.demarle at kitware.com
Mon Apr 27 12:04:19 EDT 2015
I think we've been meaning to expose those in the GUI ever since we added
those back in about paraview 3.4. Anyway, here is the syntax from a python
script I recently used them in.
where gen is the proxy for a python programmable filter
paramprop = gen.GetProperty("Parameters")
paramprop.SetElement(0, "ntimes")
paramprop.SetElement(1, str(ntimes))
paramprop.SetElement(2, "nlevels")
paramprop.SetElement(3, str(nlevels))
…
gen.UpdateProperty("Parameters")
gen.UpdatePipeline()
For more details refer to the attached benchmarking script.
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Mon, Apr 27, 2015 at 11:49 AM, Di Cheng <chengdi at imech.ac.cn> wrote:
> Hi, everyone
>
> I am using Programmable Filter in paraview. I noticed that there is a
> Parameters property in Programmable Filter. But I cannot use it in GUI,
> either in pvpython.
>
> I referred the C++ document about this filter in [
> http://www.paraview.org/ParaView3/Doc/Nightly/www/cxx-doc/classvtkPythonProgrammableFilter.html],
> It is used to pass arguments to python script. BUT, I CANNOT USE IT in
> pvpython. I think it is because it accept two or more parameters and cannot
> be wrapped by XML file.
>
> I know there is a undocumented GetClientSideObject() method which could
> work in "builtin:" mode. But it could only work locally
>
> Currently, I am using a script generator to pass arguments
> -----code-----
> def pass_arg_script(d):
> """
> generate script to pass parameters in dictionary d={'name':value}
> value can be numpy arrays
> """
> s=""
> for k in d:
> s+='self.'+k+'='+repr(d[k])+'\n'
> s+="print '"+k+"=', self."+k+'\n'
> return s
>
> pf.Script = s+ pf.Script
> ------end of code------
>
> My question is: Is there any decent way to pass Parameters to Programmable
> Filter in pvpython?
>
> Di CHENG (Ph.D. candidate)
> Supersonic Combustion Group
> State Key Laboratory of High Temperature Gas Dynamics
> Institute of Mechanics, Chinese Academy of Sciences
> ADDRESS: No.15 Beisihuanxi Road, Beijing (100190)
> P. R. China
> E-mail: chengdi at imech.ac.cn
> Phone: +86-10-82544053
> Fax: +86-10-82544034
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at:
> http://markmail.org/search/?q=Paraview-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20150427/5c626edc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: benchSynthSource.py
Type: text/x-python-script
Size: 8438 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20150427/5c626edc/attachment.bin>
More information about the Paraview-developers
mailing list