Here is the latest version that I have worked on. It has some exceptions built in because of problems we had when transferring the pickle files across machines ( windows sizes, stereo settings).<br><br><div class="gmail_quote">
On Thu, Nov 27, 2008 at 8:57 PM, Robert Maynard <span dir="ltr"><<a href="mailto:RobertJMaynard@gmail.com">RobertJMaynard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
When I get into work tomorrow I will forward the newest version that I wrote if you would like.<br><br><div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Thu, Nov 27, 2008 at 7:08 PM, Jacques Papper <span dir="ltr"><<a href="mailto:jacques.papper@gmail.com" target="_blank">jacques.papper@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">All,<br><br>I modified a script that Robert Maynard posted back in 2007 for saving and loading states. <br>
I haven't thoroughly tested it yet, but it seems to work fine for me. <br>Basically it saves only the properties of the RenderView but not the Representations property. <br>
This has for effect that you only save the camera / lightings etc settings without having to worry about what sources your viewing or representations are associated to your view.<br>I find it very useful to automate post-processing were you use a standard set of cam positions. <br>
<br>Also for those who have problems with cPickle, just use pickle instead... <br><br>Thought I'd give this back to the community - let me know if you are using it, I will probably build some more on top of this. <br>
<br><br>#!/usr/bin/env python<br><br>from paraview.servermanager import *<br>import cPickle as pickle<br>import re<br><br>class CamState:<br><br> def __init__(self):<br> #storage for a list of view objects<br> self.view = list()<br>
<br> def loadState(self,file):<br> try:<br> self.view = pickle.load(open(file))<br> except IOError:<br> print "file not found"<br><br> def saveState(self,file):<br> pickle.dump(self.view,open(file,'w'))<br>
<br> def deleteView(self,name):<br> for item in self.view:<br> if(<a href="http://item.name" target="_blank">item.name</a> == name):<br> del item<br> return True<br> return False<br>
<br> def deleteAllViews(self):<br> del self.view<br> self.view = list()<br><br> def addView(self,name):<br> newView = view(name, self.__getProperties())<br> self.view.append(newView)<br>
<br>
def loadView(self,name):<br> for v in self.view:<br> if (<a href="http://v.name" target="_blank">v.name</a> == name):<br> self.__load(v.properties)<br><br> def __getProperties(self):<br>
repreg = re.compile("Representations")<br>
properties = list()<br> view = servermanager.GetRenderView()<br> for property in view:<br> propertyName = property.Proxy.GetPropertyName(property.SMProperty)<br><br> if repreg.search(propertyName):<br>
print "Not copying Representations"<br> else:<br> try:<br> value = property.GetData()<br> float(value)<br> except(IndexError,TypeError,ValueError,AttributeError,SyntaxError):<br>
try:<br> float(value[0])<br> except(IndexError,TypeError,ValueError,AttributeError,SyntaxError):<br> pass<br> else:<br>
properties.append((propertyName,value))<br> else:<br> properties.append((propertyName,value))<br> return properties<br><br> def __load(self,properties):<br>
view = servermanager.GetRenderView()<br> for i in properties:<br> print i[0],i[1]<br> view.SetPropertyWithName(i[0],i[1])<br> view.UpdateVTKObjects()<br> view.StillRender()<br>
<br>class view:<br> def __init__(self,name,properties):<br> <a href="http://self.name" target="_blank">self.name</a> = name<br> self.properties = properties<br><br> def __getstate__(self):<br> pickleDict = dict()<br>
pickleDict['name']=<a href="http://self.name" target="_blank">self.name</a><br> pickleDict['properties']=self.properties<br> return pickleDict<br><br> def __setstate__(self,dict):<br>
<a href="http://self.name" target="_blank">self.name</a> = dict['name']<br>
<a href="http://self.name" target="_blank">self.name</a> = dict['properties']<br> self.__dict__.update(dict)<br> <br> <br><br><br><br><br><br><br><div class="gmail_quote">2008/11/27 Jacques Papper <span dir="ltr"><<a href="mailto:jacques.papper@gmail.com" target="_blank">jacques.papper@gmail.com</a>></span><div>
<div></div><div><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi everyone,<br><br>I'm trying to figure out a way of driving my post-processing through a python script.<br>
What I want to do is have a standard set of views that I can load through python (without having to reload the data every time) and output pictures for each of them.<br>
- different camera positions<br> - different scalars plotted (and different scalar bars)<br>Is using the lookmarks the best way ?<br>If it is, how do I load lookmarks through python ?<br><font color="#888888"><br>Jacques<br>
</font></blockquote></div></div></div><br>
<br></div></div>_______________________________________________<br>
ParaView mailing list<br>
<a href="mailto:ParaView@paraview.org" target="_blank">ParaView@paraview.org</a><br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br>
</blockquote></div><br>