<div dir="ltr">Hello,<div><br></div><div>I'm relatively new to VTK and I'm running into an issue with a VTK example and Python (running VTK 6 and Python 3.6 on Win7 x64).  I've got an STL file where I want to set certain cells to a given color.  I've got the cell IDs (through ray casting) and colors using a colormap from matplotlib.  From what I can tell, the ColorCellsWithRGB example should allow me to set certain triangles to a given color.  My current issue is the mesh is rendering black given the below code.  If I comment out the 'InsertTuples" line and uncomment the "InsertNextTuple3" line, triangles are represented different colors; however, it's random and looks like a kaleidoscope when it should be monochromatic. FWIW, my STL images render fine when not using the SetScalars command.  Can someone give me pointers on what I can look at next so that I can achieve my goals?<b><i>.</i></b></div><div><br></div><div><div>class Mesh:</div><div>    def __init__(self):</div><div>        self.MeshData = None</div><div>        self.__OldMeshData = None</div><div>        self.FileName = None</div><div>        self.Name = None</div><div>        </div><div>    def LoadSTL(self, filenameSTL):</div><div>        readerSTL = vtk.vtkSTLReader()</div><div>        readerSTL.SetFileName(filenameSTL)</div><div>        # 'update' the reader i.e. read the .stl file</div><div>        readerSTL.Update()</div><div>        polydata = readerSTL.GetOutput()</div><div>        # If there are no points in 'vtkPolyData' something went wrong</div><div>        if polydata.GetNumberOfPoints() == 0:</div><div>            raise ValueError(</div><div>                "No point data could be loaded from '" + filenameSTL)</div><div>            return None</div><div>        </div><div>        self.MeshData = polydata</div><div>        self.FileName = filenameSTL</div><div>        self.Name = self.FileName</div><div>        return polydata    </div><div><br></div><div><br></div><div><br></div><div><br></div><div><div>cellData = vtk.vtkUnsignedCharArray()</div><div>cellData.SetNumberOfComponents(3)</div><div>cellData.SetNumberOfTuples(laa.MeshData.GetNumberOfCells())</div><div>cellData.SetName('Colors')</div><div>for i in range(0,laa.MeshData.GetNumberOfCells()):</div><div>    cellData.InsertTuple(i,(.5,.5,.5))</div><div>    #cellData.InsertNextTuple3(.5,.5,.5)</div><div>    </div><div>laa.MeshData.GetCellData().SetScalars(cellData)</div><div>laa.MeshData.Modified()</div><div>mapper = vtk.vtkPolyDataMapper()</div><div>mapper.SetInputData(laa.MeshData)</div><div>actor = vtk.vtkActor()</div><div>actor.SetMapper(mapper)</div><div>renderer = vtk.vtkRenderer()</div><div>renderWindow = vtk.vtkRenderWindow()</div><div>renderWindow.AddRenderer(renderer)</div><div>renderWindowInteractor = vtk.vtkRenderWindowInteractor()</div><div>renderWindowInteractor.SetRenderWindow(renderWindow)</div><div>renderWindowInteractor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())</div><div>renderer.AddActor(actor)</div><div>renderer.SetBackground((1,1,1))</div><div>renderWindow.Render()</div><div>renderWindowInteractor.Start</div><div>#ren.ShowWindow()</div></div></div></div>