我正在用Python编写Paraview(5.6.0)脚本,从VTU文件创建球形glyph。脚本的相关部分如下所示。脚本完成后,将创建glyph并使用适当的参数显示,但UI不会反映所有设置。你知道吗
更具体地说,脚本说sphGlyph.ScaleArray=['POINTS','diameter']
,视图正确地显示了由diameter
数组缩放的球体;但是UI仍然说No scale array
(在下图中)。如果单击“应用”,我将丢失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)
确保在创建glyph之前调用updatePiline。
下面的代码非常适合于这个dataset。你知道吗
相关问题 更多 >
编程相关推荐