Paraview:python 脚本中的某些管道设置未反映在 UI 中

Paraview: some pipeline settings from python script not reflected in the UI

我正在 Python 中编写 Paraview (5.6.0) 脚本,从 VTU 文件创建球形字形。脚本的相关部分如下所示。脚本完成后,将使用适当的参数创建并显示字形,但 UI 并未反映所有设置。

更具体地说,脚本说 sphGlyph.ScaleArray=['POINTS','diameter'] 并且视图正确显示由 diameter 数组缩放的球体;尽管如此,UI 仍然显示 No scale array(在下图中)。如果我单击 "apply",我将丢失 diameter 设置并且视图更新为 No scale array

其他一些设置,例如 sphGlyph.ScaleFactor=1.,在 UI 和视图中都受到尊重。

在手动构建管道时,我没有看到脚本和 Python 跟踪之间有任何明显的区别。

问题出在哪里?

# ....
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()

编辑: 这是@MatthieuWespthal 建议的脚本(并下载了 cube.vtu,但未能正确设置 Scale Array

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)

确保在创建字形之前调用 UpdatePipeline。

以下内容与此 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)