[Paraview] importing for LUT xmls exported from ParaView GUI through Python

Milos Ilak ilak at mech.kth.se
Thu Sep 16 11:51:42 EDT 2010


Hi,

I needed to import a lookup table for volume plots that I saved from the GUI
into Python, and I saw that this feature is not available, and still pending
as reported here:

http://paraview.org/Bug/view.php?id=9273

I wrote a little function, attached below, that parses the xml file and
returns the LUT, the piecewise function and the color space name. It works
for me, so if you need to do this, feel free to use it. But suggestions how
to improve it are more than welcome! Regards,

Milos

-----------------------------------------------------------------------------------------------------------

import xml.dom.minidom

def colormap(filein):

    map=xml.dom.minidom.parse(filein)
    rlist=map.getElementsByTagName('Point')
    rlist2=map.getElementsByTagName('ColorMap')
    colorspace=str(rlist2[0].attributes["space"].value)

    piecewise_fun = []
    lut = []

    for i in range(len(rlist)):

        x=float(rlist[i].attributes["x"].value)
        o=float(rlist[i].attributes["o"].value)
        r=float(rlist[i].attributes["r"].value)
        g=float(rlist[i].attributes["g"].value)
        b=float(rlist[i].attributes["b"].value)

        piecewise_fun.append(x)
        piecewise_fun.append(o)

        lut.append(x)
        lut.append(r)
        lut.append(g)
        lut.append(b)

    return colorspace, piecewise_fun, lut


-- 
Miloš Ilak
Linné Flow Centre
KTH Mechanics, Stockholm
+46(0) 8 790-7152
www2.mech.kth.se/~ilak <http://www2.mech.kth.se/%7Eilak/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100916/9dfa4bbb/attachment.htm>


More information about the ParaView mailing list