# vtkAppendPolyData does not include the scalar information

**URL:** https://discourse.vtk.org/t/vtkappendpolydata-does-not-include-the-scalar-information/4850
**Category:** Support
**Created:** [December 17, 2020, 5:01pm UTC](https://discourse.vtk.org/t/vtkappendpolydata-does-not-include-the-scalar-information/4850 "2020-12-17T17:01:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [December 17, 2020, 5:01pm UTC](https://discourse.vtk.org/t/vtkappendpolydata-does-not-include-the-scalar-information/4850/1 "2020-12-17T17:01:01Z")

</div>

Hello,

I am tryng to append two polydatas with scalar info so according to the class information if both have scalar information the output should also include it. But i am trying it of many ways and the results does not include colour in the polydata. I wonder if it is a bug or someone has the same problem. If I render it separatelly without append the colour is ok but with append no colour is added, Thanks

```
vtkSmartPointer<vtkIntArray> colors1 =
	vtkSmartPointer<vtkIntArray>::New();
colors1->SetNumberOfComponents(1);
  colors1->SetNumberOfTuples
    (LineAxisThroughImplant->
 GetNumberOfPoints());
colors1->SetName("Colors1");
colors1->FillComponent(0, 100);

vtkSmartPointer<vtkIntArray> colors2 =
	vtkSmartPointer<vtkIntArray>::New();
colors2->SetNumberOfComponents(1);
colors2->
  SetNumberOfTuples
  (contour_implant->GetNumberOfPoints());
colors2->SetName("Colors2");
colors2->FillComponent(0, 255);

LineAxisThroughImplant->
   GetPointData()->AddArray(colors1);
LineAxisThroughImplant->
   GetPointData()->AddArray(colors2);
LineAxisThroughImplant->
   GetPointData()->SetScalars(colors1);
LineAxisThroughImplant->
   GetPointData()->
  SetActiveScalars("Colors1");
LineAxisThroughImplant
   ->GetPointData()->Modified();

contour_implant->
   GetPointData()->AddArray(colors2);
contour_implant->
 GetPointData()->AddArray(colors1);
contour_implant->
GetPointData()->SetScalars(colors2);
contour_implant->GetPointData()->SetActiveScalars("Colors2");
contour_implant->Modified();

vtkNew<vtkAppendPolyData>    
   AppendPolyData;
AppendPolyData->
AddInputData(contour_implant);
AppendPolyData->
AddInputData(LineAxisThroughImplant);
AppendPolyData->Update();

```

I have also tried with tuples but without success

```
  double red[3] = { 255,0,0 };
  vtkSmartPointer<vtkIntArray> colors1 =
	vtkSmartPointer<vtkIntArray>::New();
  colors1->SetNumberOfComponents(3);
colors1->
  SetNumberOfTuples
 (LineAxisThroughImplant->   
  GetNumberOfPoints());
colors1->SetName("Colors1");

vtkSmartPointer<vtkIntArray> colors2 =
	vtkSmartPointer<vtkIntArray>::New();
colors2->SetNumberOfComponents(3);
colors2->SetNumberOfTuples(contour_implant->GetNumberOfPoints());
colors2->SetName("Colors2");

for (int i = 0; i < contour_implant->GetNumberOfPoints(); i++)
	colors2->SetTuple(i,red);

for (int i = 0; i < LineAxisThroughImplant
  ->GetNumberOfPoints(); i++)
	colors1->SetTuple(i, red);

LineAxisThroughImplant
 ->GetPointData()->AddArray(colors1);
LineAxisThroughImplant->
      GetPointData()->SetScalars(colors1);
LineAxisThroughImplant->
 GetPointData()->
 SetActiveScalars("Colors1");
LineAxisThroughImplant->
  GetPointData()->Modified();

contour_implant->
 GetPointData()->
 AddArray(colors2);
contour_implant
   ->GetPointData()->SetScalars(colors2);
contour_implant->
 GetPointData()->SetActiveScalars("Colors2");
contour_implant->Modified();
```

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [December 18, 2020, 11:22am UTC](https://discourse.vtk.org/t/vtkappendpolydata-does-not-include-the-scalar-information/4850/2 "2020-12-18T11:22:15Z")

</div>

I believe only arrays with the same names are included in the result. Hope that helps.

---

<div class="post-metadata">

### Author: ![Joachim\_P](https://discourse.vtk.org/user_avatar/discourse.vtk.org/joachim_p/32/3272_2.png) [@Joachim\_P](https://discourse.vtk.org/u/Joachim_P)
#### Post date: [December 20, 2020, 11:33am UTC](https://discourse.vtk.org/t/vtkappendpolydata-does-not-include-the-scalar-information/4850/3 "2020-12-20T11:33:21Z")

</div>

Please check that both arrays (“Colors1” & “Colors2”) are correctly copied in the output mesh. If so, make sure that one of those is tagged as the `Scalars` array (I suspect it is not the case).
