import local functions in pvpython
So I have a script in my working directory which has functions I want to call in to pv python, but for some reason when I call them,
for example Code:
import os Does anyone know why this might be happening and how I can fix the issue? |
If you're in a folder with myscript.py which has a function named myFunction then
Code:
from myscript import myFunction Regards, Mikko |
seems to be working today, I must have been doing something careless yesterday, but now, although I can import the function fine, it isn't recognising the things that I call from paraview.simple. For example currently I am using the following function:
Code:
def clip(): TypeError: clip() takes exactly 1 argument (0 given) which is strange because clip() doesn't take any arguments. Secondly, if I give it an arbitrary argument, say 1 for example, I get FluentCaseReader1 = GetActiveSource() NameError: global name 'GetActiveSource' is not defined also, if I run the script in containing the functions in pv python and then call them they work fine... Any suggestions? |
The namespaces are somehow confused. Why are you importing paraview in the beginning of your function? Can you try this?
Code:
import myscript |
Code:
>>> PA.clip() Code:
>>> pv.Clip(so) |
In the beginning of your script files you should import the ParaView Simple module. Simple module contains all the filters (Clip, Slice...). Either by
Code:
from paraview.simple import * Code:
import paraview.simple as pv |
seems to have done the trick, thanks again!
|
hey you know this is weird, but I just did a clean install of paraview4.4 with openfoam from the debian package on ubuntu 15.10 and the same original problem with importing functions from the local folder has manifested. Do you have any thoughts as to why this might be?
|
All times are GMT -4. The time now is 17:22. |