Reputation: 177
I have the following bash script
for f in C:/folder/inside/my_stuff/*; do
cd "$f" &&
for file in *.ply; do
"C:\\Program Files\\ParaView 4.4.0\\bin\\paraview.exe" --script="C:\\folder\\inside\\my_stuff\\screens2.py" $file
done
done
The script is supposed to load .ply files into Paraview and then execute a number of commands, but I need to pass $file
to the Python script so it would know which file to open.
The beginning of my script looks like this:
#### import the simple module from the paraview
from paraview.simple import *
import numpy as np
import glob
import sys
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
files = sys.argv[1]
But when I run the script I get an error:
File "<string>", line 9, in <module>
AttributeError: 'module' object has no attribute 'argv'
So the variable is not passed to the script. Oddly, the .ply file does load into Paraview but none of the commands are executed. I tried sys.argv[0]
, sys.argv[2]
, sys.argv[3]
, sys.argv[file]
, sys.argv['file']
, but nothing works.
Upvotes: 2
Views: 610
Reputation: 2488
ParaView does not forward arguments to script. Unknown command line arguments are interpreted as file to open in ParaView.
Depending on what you want to do, you should either:
"C:\\Program Files\\ParaView 4.4.0\\bin\\pvpython.exe" "C:\\folder\\inside\\my_stuff\\screens2.py" $file
for
loop inside your script and reset session between each fileUpvotes: 3