<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
I am trying to create a programmable source to create a sphere, the
location of which updates per time step based on coordinates in a
csv file. However, I have sort of got my head around the python
library (thanks to tracing what I do in the GUI!), but I think one
needs to use the vtk library instead? I have written a python script
which does the job when called from the python shell, but this is
not updating when the timestep changes. I have tried adapting this
code to work as a programmable source, but to no avail. <br>
<br>
Here is the code for the programmable source I have so far:<br>
<font size="-1"><br>
import vtk<br>
import os<br>
import csv<br>
<br>
csvfilename = '../../resources/vtk/testpos.csv'<br>
csvfilename= os.path.abspath(csvfilename)<br>
<br>
animationScene1 = GetAnimationScene()<br>
target = int(animationScene1.AnimationTime)<br>
print "Target value is: " + str(target)<br>
<br>
pos = [0.0, 0.0, 0.0]<br>
count=0<br>
with open(csvfilename) as f:<br>
r = csv.reader(f)<br>
for row in r:<br>
print "Current row :" + str(row)<br>
if count == target:<br>
print "found it"<br>
pos = [float(i) for i in row]<br>
break<br>
count += 1<br>
print "Pos is now : " + str(pos)<br>
<br>
s=vtk.vtkSphereSource()<br>
s.SetCenter(pos)<br>
s.SetRadius(10)<br>
s.Update()</font><br>
<br>
<br>
The csv stuff works as far as I can tell, but it gives an error
because GetAnimationScene is not defined. However, there is another
problem, even if I ignore all of the time dependent things and just
try to create a sphere in this manner: <br>
<br>
<font size="-1">import vtk</font><br>
<font size="-1">s=vtk.vtkSphereSource()<br>
s.SetCenter([0,0,0])<br>
s.SetRadius(10)<br>
s.Update()<br>
</font><br>
there are no errors, but no sphere either! So I guess I am missing
something fundamental about the difference between python scripting
and programmable sources. Further, I wonder if it would be easier to
change the position of an already created sphere source with a
programmable filter instead?<br>
<br>
Has anybody solved a similar problem and can point me in the correct
direction? Any help would be greatly appreciated.<br>
<br>
Kind regards,<br>
<br>
James
</body>
</html>