Hello together,

 

I wrote a short python script to create slices with local coordinate systems
in ParaView. Sometimes then the script should create a new slide with
defined parameter about scalar factor, origin and normal vector, the
function returns a value error.  The message told me that the point data
array cannot be found in the simulation. I tested the function with a lot of
different parameters and recognizes that the function does not fail because
of the variance of parameters. After repeating of calling the function with
the same parameters, the function worked sometimes and it fails. So now I
don't know if it is a mistake of myself or it is a bug in ParaView. 

Maybe you can give me a short answer about it. Thank you all.

 

I used ParaView on a Linux machine calling the pvbatch with the script as
parameter from the shell. The script is append at the end of this mail.

 

Regards,

 

Christian

class modSlice(object):
    def __init__(self, name, origin, normal, scalar, extrema):
        #attributes
        self.error = False
        #create the new slice
        self.newSlice = Slice(SliceType="Plane")
        RenameSource(name, self.newSlice)
        self.newSlice.SliceOffsetValues = []
        self.newSlice.SliceType.Origin = origin
        self.newSlice.SliceType.Normal = normal
        #SetActiveSource(FindSource(name))
        #Data
        DataRepresentation = Show()
        DataRepresentation.EdgeColor = [0.0, 0.0, 0.5000076295109483]
        DataRepresentation.ColorAttributeType = 'POINT_DATA'
        DataRepresentation.SelectionPointFieldDataArrayName = scalar
        try:
                DataRepresentation.ColorArrayName = scalar
        except ValueError:
                self.error = True
        finally:        
                if self.error == False:
                        DataRepresentation.ScaleFactor = 0.02000000011175871
                        #scalar bar
                        lookUpTable = None
                        unit = None
                        if scalar == "U":
                                lookUpTable = GetLookupTableForArray( scalar, 
1, NanColor=[0.4980392156862745, 0.4980392156862745, 0.4980392156862745], 
RGBPoints=[extrema[0], 0.0, 0.0, 1.0, extrema[1], 1.0, 0.0, 
0.0],VectorMode='Magnitude')
                                unit = "(m/s)"
                        elif scalar == "T":
                                lookUpTable = GetLookupTableForArray( scalar, 
1,  RGBPoints=[extrema[0], 0.0, 0.0, 1.0, extrema[1], 1.0, 0.0, 0.0], 
ColorSpace='HSV' )
                                unit = "(K)"
                        elif scalar == "p":
                                lookUpTable = GetLookupTableForArray( scalar, 
1,  RGBPoints=[extrema[0], 0.0, 0.0, 1.0, extrema[1], 1.0, 0.0, 0.0], 
ColorSpace='HSV' )
                                unit = "(Pa)"
                        DataRepresentation.LookupTable = lookUpTable
                        scalarBarTitle = ' '.join((scalar, unit))
                        self.ScalarBar = CreateScalarBar(ComponentTitle='', 
Title= scalarBarTitle, Enabled=1, LabelFontSize=12, LabelColor=[0.0, 0.0, 0.0], 
LookupTable=lookUpTable, TitleFontSize=12, TitleColor=[0.0, 0.0, 0.0])
                        #change position of scalarbar
                        #self.ScalarBar.Position = [0.25, 0.1]
                        #self.ScalarBar.Position = [0.5, 0.8]
                        GetRenderView().Representations.append(self.ScalarBar)
                        #set plane's frame visibility off
                        active_objects.source.SMProxy.InvokeEvent('UserEvent', 
'HideWidget')
                        Render()
                else:
                        
                        print "Bug occured. Slice won't be created."
_______________________________________________
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

Reply via email to