[Paraview] Spline Source and python script
Ian Leslie
lesl4685 at vandals.uidaho.edu
Sun Nov 27 15:00:16 EST 2011
Shima,
I've CC this to the paraview mailing list, so that others might help.
I am sorry to tell you that I don't know of a way this could be accomplished, as I have very little experience with python scripting. I would also like to be able to read in a .csv file and produce splines or lines. Some information on python scripting within paraview is given here http://www.cmake.org/Wiki/ParaView#Python_Scripting, and I was directed to this site from the vtk mailing list, but the code is not written for python http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/PolyLine . My best suggestion would be to place your .csv file into a text format and try to copy and paste the xyz coordinates, just be careful of spacing changes between text from the copy and paste. This is what I plan on doing.
Ian
Date: Sun, 27 Nov 2011 10:23:04 +0100
Subject: Re: [Paraview] Spline Source and python script
From: sh.s.mostafavi at gmail.com
To: lesl4685 at vandals.uidaho.edu
Hello Lan,
I read your code. it was really helpful for me as i had the same problem as yours. but I still need some infos. how to have access to a file which contains more than 100 points with their coordinates. Because it takes too much time to enter them in the script by their coordinates. my file is a ".csv" one and I don't know how to access that via the python shell or Macro.
If you could help me, I would be very thankful
Shima
On Sun, Nov 27, 2011 at 3:00 AM, Ian Leslie <lesl4685 at vandals.uidaho.edu> wrote:
Thanks Jerome! I got it to work. The copy and paste limitation must have been the problem. I hand typed it in and saved it as a macro and then added
DataRepresentation1 = Show()DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483] before Render() and everything seems to work fine.
Below is the code I used for the macro for anyone else who may need this. Worked for me running ParaView 3.12.0-RC3.
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
s = SplineSource()
s.ParametricFunction.SetPropertyWithName("Closed",1)
pointA = [1,2,3]
pointB = [6,5,4]
pointC = [7,8,9]
s.ParametricFunction.SetPropertyWithName("Points", pointA+pointB+pointC)
DataRepresentation1 = Show()DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483]
Render()
Ian
Date: Sat, 26 Nov 2011 21:43:47 +0100
From: jerome.velut at kitware.com
To: lesl4685 at vandals.uidaho.edu
CC: paraview at paraview.org
Subject: Re: [Paraview] Spline Source and python script
Hum... I guess you copied my code lines and pasted them in the python shell, right?
I found a limitation of the python shell, but I didn't take the time to report it: when I copy several lines from a file to the paraview python shell, they are not executed. Moreover, the unix-style "middle click direct copied" line is also not executed, though the characters are well written!!
Try this:
- copy/paste the lines one by one with ctrl+c / ctrl+v method
- or (prefered!) create a file that you execute as a macro from the "Macros" menu
- or re-type by hand all the lines ;)
FYI, I compile frequently the git-master and this method always worked for me. So should be with 3.12.
HTH,
Jerome
On 11/26/2011 09:18 PM, Ian Leslie wrote:
Hi Jerome,
Thanks for explaining in more detail. I tried the script but only two spline points were produced at 0,0,0 and 1,0,0. No errors are given, so I can't point to a line in the code. I am running ParaView 3.12.0, perhaps something changed between 3.10 and 3.12 to affect the script? It is also possible I am overlooking something very obvious as I have only just started to use the python scripting in paraview.
This is the script I ran in the python shell
s = SplineSource()
s.ParametricFunction.SetPropertyWithName( "Closed", 1 )
pointA = [1,2,3]
pointB = [6,5,4]
pointC = [7,8,9]
s.ParametricFunction.SetPropertyWithName( "Points", pointA+pointB+pointC)
My goal is to have a python script that will take multiple point locations given in the script or from a file and produce a spline without having to manually enter them into the spline source one at a time. Open to any suggestions and all ideas.
Thanks,
Ian
Date: Sat, 26 Nov 2011 13:02:12 +0100
From: jerome.velut at gmail.com
To: lesl4685 at vandals.uidaho.edu
CC: paraview at paraview.org
Subject: Re: [vtkusers] Spline Source and python script
Hi,
it is more a ParaView-related question, so I changed the list name ;)
I tried again the solution Pat proposed in the post, and I am sorry to tell you that it works without changing anything...
I just can be more precise. Please follow these steps in the paraview python shell :
s = SplineSource()
s.ParametricFunction.SetPropertyWithName( "Closed", 1 ) # Now, the "Closed Spline" property toggles to "checked"
pointA = [1,2,3]
pointB = [6,5,4]
pointC = [7,8,9]
s.ParametricFunction.SetPropertyWithName( "Points", pointA+pointB+pointC) # Now, the three points appear in the spline points list
Then press apply : the spline appears in the render window.
If you experience problems, please tell me which steps are guilty.
HTH,
Jerome
On 11/26/2011 08:04 AM, Ian Leslie wrote:
Hi,
I saw your post on getting the spline function to work in the pyhthon shell within ParaView on the vtk.org users mailing list and was wondering if you would be willing to share your solution with me. I wasn't able to implement the suggested solution based on the post alone http://markmail.org/search/list:paraview?q=SplineSource+and+python+script#query:list%3Aparaview%20SplineSource%20and%20python%20script+page:1+mid:hhzkv5vj33zv6hky+state:results
Thanks,
Ian
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20111127/70e23165/attachment.htm>
More information about the ParaView
mailing list