invalid array name

I write
calculator = vtk.vtkArrayCalculator() calculator.SetInputConnection(cellToPoint.GetOutputPort()) calculator.SetAttributeType(vtk.vtkDataObject.POINT ) print(calculator.GetNumberOfScalarArrays()) calculator.AddScalarArrayName("VelocityX",0)
and I think it’s no problem,but the command windows get me a error message invalid array name "VelocityX",I do not konw where is wrong ,who can help me.Thanks.By the way,the cellToPoint.GetOutputPort() output type is vtkPolyData

Hi, Hao,

You have to set the name of the scalar array when you create it:

   vtkSmartPointer<vtkFloatArray> values = vtkSmartPointer<vtkFloatArray>::New();
   values->SetName("VelocityX");

kind regards,

Paulo

Also, depending on how your code structure is designed, your calculator object is going out of scope, thereby destroying your “Velocity0” scalar field before the VTK framework has a chance to use it.