# Trivial Producer Scalars not Visible? (Part of increasing understanding of VTK + Paraview scripting)

**URL:** https://discourse.paraview.org/t/trivial-producer-scalars-not-visible-part-of-increasing-understanding-of-vtk-paraview-scripting/10216
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [August 29, 2022, 9:20pm UTC](https://discourse.paraview.org/t/trivial-producer-scalars-not-visible-part-of-increasing-understanding-of-vtk-paraview-scripting/10216 "2022-08-29T21:20:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [August 29, 2022, 9:20pm UTC](https://discourse.paraview.org/t/trivial-producer-scalars-not-visible-part-of-increasing-understanding-of-vtk-paraview-scripting/10216/1 "2022-08-29T21:20:25Z")

</div>

Hi there,

I’m trying to improve my understanding of both paraview and vtk’s python module by generating small point sets and viewing them in paraview using the Trivial Producer. I succeed in getting points drawn to the screen with this code when I use `Run Script` in paraview, but there’s no clear way to see the scalar data set on the points.

```auto
import numpy as np
from paraview.simple import *
import paraview.vtk as vtk
from paraview.vtk.numpy_interface import dataset_adapter as dsa
import paraview.vtk.util.numpy_support as vnp

node = np.array(
        [[0.0, 0.0, 0.0],
         [1.0, 0.0, 0.0],
         [1.0, 1.0, 0.0],
         [0.0, 1.0, 0.0]], dtype=np.float)

NC = cell.shape[0]

points = vtk.vtkPoints()
points.SetData(vnp.numpy_to_vtk(node))
vpoly = vtk.vtkPolyData()
vpoly.SetPoints(points)

# create scalars
s = vtk.vtkFloatArray()
s.InsertTuple1(0,20.0)
s.InsertTuple1(1,30.0)
s.InsertTuple1(2,50.0)
s.InsertTuple1(3,50.0)

vcells = vtk.vtkCellArray()

for i in range(node.shape[0]):
	vcells.InsertNextCell(1)
	vcells.InsertCellPoint(i)

vpoly.SetVerts(vcells)

vpoly.GetPointData().SetScalars(s)
# how to put uGrid into the following codes
view = GetActiveViewOrCreate('RenderView') 

# create a trivial producer to bridge between the VTK object and ParaView
tp = TrivialProducer()
tp.GetClientSideObject().SetOutput(vpoly)

dispaly = Show(tp)

#Interact()

```

Funnily enough if I use the vtp extractor then I can open a resulting vtp file and see the scalar data, but I’d prefer not to do those several extra steps just to view some small changes in the values I write in the python script.

Here’s what things look like in paraview. I’m unsure if the error that comes up is related to the missing data displayed

 ![image](https://discourse.paraview.org/uploads/default/original/2X/4/44577df40f61dbdfa6179316ad41631f6aeac77e.png)

So the question is, how can I use trivial producer to show scalar data on a vtkPolyData object I’ve written from scratch? In a larger sense this question is also asking “what is the preferred way to use vtk and paraview scripting together?”

Thanks for any support on this matter!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 30, 2022, 12:47am UTC](https://discourse.paraview.org/t/trivial-producer-scalars-not-visible-part-of-increasing-understanding-of-vtk-paraview-scripting/10216/2 "2022-08-30T00:47:33Z")

</div>

> the error

Name your array

> the question is, how can I use trivial producer to show scalar data on a vtkPolyData object I’ve written from scratch?

Yes, but only in built-in mode, not in server mode.

> In a larger sense this question is also asking “what is the preferred way to use vtk and paraview scripting together?”

Programmable source/Filter

---

<div class="post-metadata">

### Author: ![Devin\_Richard\_Bayly](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devin_richard_bayly/32/5533_2.png) [@Devin\_Richard\_Bayly](https://discourse.paraview.org/u/Devin_Richard_Bayly)
#### Post date: [August 30, 2022, 9:00pm UTC](https://discourse.paraview.org/t/trivial-producer-scalars-not-visible-part-of-increasing-understanding-of-vtk-paraview-scripting/10216/3 "2022-08-30T21:00:53Z")

</div>

Thank you for the concise yet comprehensive run through of my questions!

Oh woops, yes I was totally expecting something like `_Scalars` by default but that was wrong. Sure enough adding `s.SetName("test")` did the trick.

Great I’ll make sure I understand those better as they are the preferred route to make use of python vtk within paraview.

Cheers
