找到你要的答案

Q:Add custom property to a Paraview source

Q:添加自定义属性设置为ParaView源

I'm interested whether I can add a custom property to a source I generate. What I'm now doing is the following:

renderView1 = GetActiveViewOrCreate('RenderView')

for pset in sphereParams:
    sphere = Sphere()
    sphere.Center = pset[0:3]
    sphere.Radius = pset[3]
    Show(sphere, renderView1)

    spheres.append(sphere)

Now I would want to visualize the spheres such that the colour corresponds to another parameter which is stored also in the sphereParams vector. How does one add such a property to a Paraview source?

Thanks!

我感兴趣的是是否可以将自定义属性添加到生成的源中。我现在正在做的是以下内容:

renderView1 = GetActiveViewOrCreate('RenderView')

for pset in sphereParams:
    sphere = Sphere()
    sphere.Center = pset[0:3]
    sphere.Radius = pset[3]
    Show(sphere, renderView1)

    spheres.append(sphere)

现在我想把球这样的颜色对应的另一个参数存储在sphereparams向量。如何添加这样的属性对ParaView来源吗?

谢谢!

answer1: 回答1:

You could manually set the color based on the property

renderView1 = GetActiveViewOrCreate('RenderView')

for pset in sphereParams:
    sphere = Sphere()
    sphere.Center = pset[0:3]
    sphere.Radius = pset[3]
    sphereDisplay = Show(sphere, renderView1)
    sphereDisplay.DiffuseColor = ... # 3-element list specifying color from sphere params

    spheres.append(sphere)

可以根据属性手动设置颜色

renderView1 = GetActiveViewOrCreate('RenderView')

for pset in sphereParams:
    sphere = Sphere()
    sphere.Center = pset[0:3]
    sphere.Radius = pset[3]
    sphereDisplay = Show(sphere, renderView1)
    sphereDisplay.DiffuseColor = ... # 3-element list specifying color from sphere params

    spheres.append(sphere)
answer2: 回答2:

You can't, what you need to do is to change the color map of the visualization or to add a pointarray/cellarray (for example, with Calculator or ProgrammableFilter) to the output of the sphere source

你不能,你需要做的是改变显示颜色图或添加一个点阵/电池方阵(例如,用计算器或programmablefilter)球体的源输出

python  paraview