I have some points and attributes (scalar, vector) originally in hdf5, and convert to a VTU file with python. I can define Point Gaussians at the points but they are always gray.I cannot seem to get a scalar attribute to colour them.
Here, without the hdf5, is example code, using pvpython (Paraview 5.9.0):
import vtk
x = [[0, 0, 0], [1, 0, 0], [2, 0, 0], [0, 1, 0],
[1, 1, 0], [2, 1, 0], [0, 0, 1], [1, 0, 1],
[2, 0, 1], [0, 1, 1], [1, 1, 1], [2, 1, 1],
[0, 1, 2], [1, 1, 2], [2, 1, 2], [0, 1, 3],
[1, 1, 3], [2, 1, 3], [0, 1, 4], [1, 1, 4],
[2, 1, 4], [0, 1, 5], [1, 1, 5], [2, 1, 5],
[0, 1, 6], [1, 1, 6], [2, 1, 6]]
points = vtk.vtkPoints()
for i in range(0, len(x)):
points.InsertPoint(i, x[i])
ugrid = vtk.vtkUnstructuredGrid()
ugrid.SetPoints(points)
wf = vtk.vtkXMLUnstructuredGridWriter()
wf.SetFileName('simple1.vtu')
wf.SetInputDataObject(ugrid)
wf.Write()
vt = vtk.vtkFloatArray()
for i in range(0,len(x)):
vt.InsertValue(i,x[i][2]/6.0)
vt.SetName('x')
fd=vtk.vtkFieldData()
fd.AddArray(vt)
ugrid.SetFieldData(fd)
wf.SetFileName('simple2ad.vtu')
wf.Write()
I open the simpl2ad.vtu file, the Information tab shows x as range [0,1] and the Bounds as expected.
Set Properties to Outline, Coloring to Solid Color, and I see the enclosing box.
Set representation to Point Gaussian, coloring to “x”, see gray balls.
As an experiment (one of many) I add a PythonCalculator with expression (inputs[0].FieldData[‘x’]) association Point Data, representation Point Gaussian, Coloring to “result”, and see gray balls. (I can print that expression and see the x values in Output Messages tab).
Both with and without PythonCalculator it shows a color legend but nothing seems to change the colours.
Any hints what might be wrong?
John