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

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Thu Sep 16 12:36:55 EDT 2010


Thanks for sharing Milos.

Utkarsh

On Thu, Sep 16, 2010 at 11:51 AM, Milos Ilak <ilak at mech.kth.se> wrote:
> 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
>
>
>
> _______________________________________________
> Powered by 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