[Paraview] Extracting blocks from a large pvd file with Python

Matthew Jackson matthew.jackson at ch.abb.com
Wed Jan 28 11:21:20 EST 2015


Hello,

I am trying to use Python to extract all of the files in a pvd file with the Extract Block filter. This loop takes too much time (over a minute) for pvd files containing more than about 100 entries, and is unusable for any pvd files that are much bigger. I have run out of ideas to speed it up, and I don't know if there is a memory leak or other problem with my code, or if this is just a side effect of dealing with such large pvd files. Any help fixing or avoiding this problem would be greatly appreciated.

Here is the relevant code

                                inputFile = open(pvdFilePath)

                                lines = inputFile.readlines()

                                pm = servermanager.ProxyManager()
                                view = GetRenderView()

                                i = 2 # Block Indices in PVDReader object begin at 2 and are incremented by 2.

                                for line in lines:

                                                words = line.split(" ")

                                                if words[0] == "<DataSet":           # Indicates this line references a .vtu file

                                                                name = words[1].split("\"")[1] # e.g. Returns 'NAME' from 'group="NAME"'

                                                                SetActiveSource(source)

                                                                ex = ExtractBlock()
                                                                ex.BlockIndices = [i]
                                                                i += 2

                                                                rep = servermanager.CreateRepresentation(ex, view)
                                                                pm.RegisterProxy("representations",name,rep)

                                                                RenameSource(name, ex)

                                                                del ex
                                                                del rep

Best Regards,
Matthew Jackson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150128/65e17231/attachment.html>


More information about the ParaView mailing list