[Paraview] Lookmarks with Python

Robert Maynard RobertJMaynard at gmail.com
Thu Nov 27 20:57:44 EST 2008


When I get into work tomorrow I will forward the newest version that I wrote
if you would like.

On Thu, Nov 27, 2008 at 7:08 PM, Jacques Papper <jacques.papper at gmail.com>wrote:

> All,
>
> I modified a script that Robert Maynard posted back in 2007 for saving and
> loading states.
> I haven't thoroughly tested it yet, but it seems to work fine for me.
> Basically it saves only the properties of the RenderView but not the
> Representations property.
> 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.
> I find it very useful to automate post-processing were you use a standard
> set of cam positions.
>
> Also for those who have problems with cPickle, just use pickle instead...
>
> 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.
>
>
> #!/usr/bin/env python
>
> from paraview.servermanager import *
> import cPickle as pickle
> import re
>
> class CamState:
>
>     def __init__(self):
>         #storage for a list of view objects
>         self.view = list()
>
>     def loadState(self,file):
>         try:
>             self.view = pickle.load(open(file))
>         except IOError:
>             print "file not found"
>
>     def saveState(self,file):
>         pickle.dump(self.view,open(file,'w'))
>
>     def deleteView(self,name):
>         for item in self.view:
>             if(item.name == name):
>                 del item
>                 return True
>         return False
>
>     def deleteAllViews(self):
>         del self.view
>         self.view = list()
>
>     def addView(self,name):
>         newView = view(name, self.__getProperties())
>         self.view.append(newView)
>
>     def loadView(self,name):
>         for v in self.view:
>             if (v.name == name):
>                 self.__load(v.properties)
>
>     def __getProperties(self):
>         repreg = re.compile("Representations")
>         properties = list()
>         view = servermanager.GetRenderView()
>         for property in view:
>             propertyName =
> property.Proxy.GetPropertyName(property.SMProperty)
>
>             if repreg.search(propertyName):
>                 print "Not copying Representations"
>             else:
>                 try:
>                     value = property.GetData()
>                     float(value)
>
> except(IndexError,TypeError,ValueError,AttributeError,SyntaxError):
>                     try:
>                         float(value[0])
>
> except(IndexError,TypeError,ValueError,AttributeError,SyntaxError):
>                         pass
>                     else:
>                         properties.append((propertyName,value))
>                 else:
>                     properties.append((propertyName,value))
>         return properties
>
>     def __load(self,properties):
>         view = servermanager.GetRenderView()
>         for i in properties:
>             print i[0],i[1]
>             view.SetPropertyWithName(i[0],i[1])
>         view.UpdateVTKObjects()
>         view.StillRender()
>
> class view:
>     def __init__(self,name,properties):
>         self.name = name
>         self.properties = properties
>
>     def __getstate__(self):
>         pickleDict = dict()
>         pickleDict['name']=self.name
>         pickleDict['properties']=self.properties
>         return pickleDict
>
>     def __setstate__(self,dict):
>         self.name = dict['name']
>         self.name = dict['properties']
>         self.__dict__.update(dict)
>
>
>
>
>
>
>
>
> 2008/11/27 Jacques Papper <jacques.papper at gmail.com>
>
> Hi everyone,
>>
>> I'm trying to figure out a way of driving my post-processing through a
>> python script.
>> 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.
>>  - different camera positions
>>  - different scalars plotted (and different scalar bars)
>> Is using the lookmarks the best way ?
>> If it is, how do I load lookmarks through python ?
>>
>> Jacques
>>
>
>
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20081127/5ce575ab/attachment-0001.htm>


More information about the ParaView mailing list