<HTML>
<HEAD>
<TITLE>Re: [Paraview] Passing a python script parameters</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>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.<BR>
<BR>
-Ken<BR>
<BR>
<BR>
On 5/12/09 12:58 PM, "David Doria" <<a href="daviddoria@gmail.com">daviddoria@gmail.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>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):<BR>
<BR>
<BR>
>>> os.listdir(".")<BR>
<BR>
['IterateOpenSources.py', 'IterateOpenSources.py~', 'LoadMultipleFiles.py', 'LoadMultipleFiles.py~', 'Sphere.py']<BR>
<BR>
>>> from LoadMultipleFiles import *<BR>
<BR>
and here is the contnets of LoadMultipleFiles.py<BR>
--------------------------<BR>
#!/usr/bin/pvpython<BR>
def LoadMultipleFiles(FilePrefix, Low, High):<BR>
#setup paraview connection<BR>
from paraview import servermanager<BR>
<BR>
if not servermanager.ActiveConnection:<BR>
connection = servermanager.Connect()<BR>
<BR>
pm = servermanager.ProxyManager()<BR>
#actually do something here<BR>
---------------------------<BR>
<BR>
You can see the function requires a couple of parameters - how can I pass them?<BR>
<BR>
Thanks,<BR>
<BR>
David<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'><BR>
**** Kenneth Moreland<BR>
*** Sandia National Laboratories<BR>
*********** <BR>
*** *** *** email: <a href="kmorel@sandia.gov">kmorel@sandia.gov</a><BR>
** *** ** phone: (505) 844-8919<BR>
*** web: <a href="http://www.cs.unm.edu/~kmorel">http://www.cs.unm.edu/~kmorel</a><BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT>
</BODY>
</HTML>