[Paraview] Passing a python script parameters

Moreland, Kenneth kmorel at sandia.gov
Wed May 13 09:02:55 EDT 2009


I have no idea what the problem is.  If you use the "Run Script" button to run the LoadMultipleFiles.py file, it creates a LoadMultipleFiles() function just like if you used the "from X import Y" command (which, incidentally, should also work assuming your python path is correct).  I just tried it and it works fine.

-Ken


On 5/12/09 12:58 PM, "David Doria" <daviddoria at gmail.com> wrote:

In the python shell, there is a "Run Script" button. It seems that you can only run scripts that do not require parameters? If I have a python function in a .py file, how would I call it? In normal python, I would import the function like this (the listdir was just to show you I was in the correct directory):


>>> os.listdir(".")

['IterateOpenSources.py', 'IterateOpenSources.py~', 'LoadMultipleFiles.py', 'LoadMultipleFiles.py~', 'Sphere.py']

>>> from LoadMultipleFiles import *

and here is the contnets of LoadMultipleFiles.py
--------------------------
#!/usr/bin/pvpython
def LoadMultipleFiles(FilePrefix, Low, High):
    #setup paraview connection
    from paraview import servermanager

    if not servermanager.ActiveConnection:
        connection = servermanager.Connect()

    pm = servermanager.ProxyManager()
    #actually do something here
---------------------------

You can see the function requires a couple of parameters - how can I pass them?

Thanks,

David



   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090513/61ffbd80/attachment.htm>


More information about the ParaView mailing list