[Paraview] help with a simple script?

Celia Bremer fuwsle at hotmail.com
Fri Nov 16 10:11:54 EST 2012


Seb,

Yes! Thank you so much! I thought I'd looked at that wiki page forever, but apparently not enough since I missed that part.

I've another question. I can run everything from the Python shell from the Paraview GUI fine, but if I do the same thing from pvpython, I get lots of errors. (I want to use pvpython so I can Disconnect() after I'm done with a state to get rid of all the stuff, instead of deleting the objects one at a time. Unless there's a reset command that I'm missing?) For example:

from paraview import servermanager
from paraview.simple import *
servermanager.LoadState("test.pvsm")
view = GetActiveView()
view.ViewTime

AttributeError: 'NoneType' object has no attribute 'ViewTime'

I don't know if it's not finding the state file and keeping quiet (though I actually used an absolute path when doing this, both from Python shell in PV and from pvpython, so I don't know why) or if it's something else. Thank you,

Celia

________________________________
> Date: Fri, 16 Nov 2012 06:46:17 -0500
> Subject: Re: [Paraview] help with a simple script?
> From: sebastien.jourdain at kitware.com
> To: fuwsle at hotmail.com
> CC: paraview at paraview.org
>
> Hi Celia,
>
> if you use the vtkWriter directly without using a proxy you will need to do:
>
> writer.SetInput(o.GetClientSideObject())
>
> But the better way to do that is by following
>
> http://www.paraview.org/Wiki/ParaView/Python_Scripting#Writing_Data_Files_.28ParaView_3.9_or_later.29
>
> And maybe, you might be interested in looking at some other examples
> here: http://www.paraview.org/Wiki/Python_recipes
>
> Hope that helps,
>
> Seb
>
>
> On Thu, Nov 15, 2012 at 10:22 PM, Celia Bremer
> <fuwsle at hotmail.com<mailto:fuwsle at hotmail.com>> wrote:
>
> Tim,
> Thank you. I should've said that I tried that but it didn't work. The
> "regular" trace gave a bunch of errors when I tried to run it. When I
> did smtrace.start_trace(CaptureAllProperties=True) , that recorded more
> stuff, like the parameters that I used in the various filters, and it
> didn't give any errors when I ran it, but it also didn't save the VTI
> files, which is my goal.
> The trace didn't include any output filenames so, apparently, the
> saving part doesn't get recorded. The last line in the trace is just
> Render(). Rendering is a part of the process when doing "Save data", at
> least when the object is hidden like in my pipeline, so it makes sense
> that it's last. But the rest of what's involved in "save data" isn't
> captured by the trace.
> Celia
>
> ----------------------------------------
>> Date: Thu, 15 Nov 2012 19:22:24 -0500
>> From: tim.gallagher at gatech.edu<mailto:tim.gallagher at gatech.edu>
>> To: fuwsle at hotmail.com<mailto:fuwsle at hotmail.com>
>> CC: paraview at paraview.org<mailto:paraview at paraview.org>
>> Subject: Re: [Paraview] help with a simple script?
>>
>> Use the Paraview trace feature
> (http://paraview.org/Wiki/Python_GUI_Tools#Trace) in the GUI when you
> do it once and save that.
>>
>> Then it's easy to edit the resulting script to loop over the files
> you need.
>>
>> Tim
>>
>> ----- Original Message -----
>> From: "Celia Bremer" <fuwsle at hotmail.com<mailto:fuwsle at hotmail.com>>
>> To: paraview at paraview.org<mailto:paraview at paraview.org>
>> Sent: Thursday, November 15, 2012 7:20:12 PM
>> Subject: [Paraview] help with a simple script?
>>
>>
>>
>> Hello,
>>
>> I want to write a script that would open a saved state, select one of
> the objects, and save data from that object as a VTI file series. I can
> do this with the GUI, but it takes many hours to do this to each file
> and I have about 60 of them, so a script would be nice since I could
> loop through the different states. But I can't figure out how to tell
> PV what I want to render, and I also can't find how to access options
> like "save time series".
>>
>> ---
>> from paraview.simple import *
>> import paraview.vtk.io<http://paraview.vtk.io> as vtk_io
>> servermanager.LoadState("test.pvsm")
>> o=FindSource("Outer Mesh") # this is the name of the Gaussian
> resampling filter
>> SetActiveSource(o) # it shows up if I do Show(o) so I know PV found it
>>
>> writer = vtk_io.vtkXMLImageDataWriter()
>> writer.SetInput(o)
>> # TypeError: argument 1: method requires a VTK object
>> # how do I specify that I want o as input, and that I want to save it
> as a file series?
>>
>> writer.SetFileName("test.vti")
>> writer.Write()
>>
>> # delete everything, load another state, repeat
>> ---
>>
>> I would appreciate any pointers.
>>
>> Celia
>> _______________________________________________
>> Powered by www.kitware.com<http://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<http://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
> 		 	   		  


More information about the ParaView mailing list