0
votes

I am scripting Paraview (5.6.0) in Python, creating spherical glyphs from a VTU file. Relevant part of the script is shown below. After the script finishes, the glyphs are created and shown with proper parameters but the UI is not reflecting all the settings.

More specifically, the script says sphGlyph.ScaleArray=['POINTS','diameter'] and the view is correctly displaying spheres scaled by the diameter array; the UI nevertheless still says No scale array (in the image below). If I click "apply", I lose the diameter setting and the view updates to No scale array.

Some other settings, like sphGlyph.ScaleFactor=1., are respected both in the UI and in the view.

I don't see any obvious difference between the script and Python trace when constructing the pipeline by hand.

Where is the problem?

# ....
vtuFile="/tmp/burnt.vtu"
view=GetActiveViewOrCreate('RenderView')
# ...
sph=XMLUnstructuredGridReader(FileName=[vtuFile])
RenameSource(vtuFile,sph)
sphGlyph=Glyph(Input=sph,GlyphType='Sphere',GlyphMode='All Points')
sphGlyph.ScaleFactor=1.
sphGlyph.ScaleArray=['POINTS','diameter']    ### <---- SET HERE
sphGlyph.GlyphType.ThetaResolution=32
sphGlyph.GlyphType.PhiResolution=32
sphGlyphShow=Show(sphGlyph,view)
sphGlyphShow.Opacity=0.5
sphGlyphShow.BackfaceRepresentation='Surface'

view.Update()

state after loading paraview

EDIT: This is the script suggested by @MatthieuWespthal (and downloaded cube.vtu which fails to set Scale Array correctly:

from paraview.simple import *
cubevtu=XMLUnstructuredGridReader(FileName=['cube.vtu'])
glyph1 = Glyph(Input=cubevtu,GlyphType='Arrow')
glyph1.OrientationArray = ['POINTS', 'No orientation array']
glyph1.ScaleArray = ['POINTS', 'f1']
glyph1.ScaleFactor = 0.1
glyph1.GlyphTransform = 'Transform2'
renderView1 = GetActiveViewOrCreate('RenderView')
glyph1Display = Show(glyph1, renderView1)

enter image description here

1

1 Answers

1
votes

Make sure to call UpdatePipeline before creating the glyph.

The following works perfectly with this dataset.

from paraview.simple import *

# find source
cubevtu = FindSource('cube.vtu')
cubevtu.UpdatePipeline()


# create a new 'Glyph'
glyph1 = Glyph(Input=cubevtu,
    GlyphType='Arrow')
glyph1.OrientationArray = ['POINTS', 'No orientation array']
glyph1.ScaleArray = ['POINTS', 'f1']
glyph1.ScaleFactor = 0.1 
glyph1.GlyphTransform = 'Transform2'

# Properties modified on glyph1

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')

glyph1Display = Show(glyph1, renderView1)