<div dir="ltr">Try colors.InsertNextTupleValue([red, green, blue])<div><br></div><div>I'm not sure about the python signature of the method, I load colors in my c++ code like this:</div><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000">auto colors = vtkSmartPointer<vtkUnsignedCharArray>::New();</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> colors-><span style="font-style:italic">SetNumberOfComponents</span>(3);</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> for(vtkIdType iIndex = 0; iIndex < numberOfPoints; ++iIndex)</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> {</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> unsigned char color[3] =</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> {</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> m_CloudData->at(iIndex).r,</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> m_CloudData->at(iIndex).g,</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> m_CloudData->at(iIndex).b</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> };</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> colors-><span style="font-style:italic">InsertNextTupleValue</span>(color);</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> }</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> auto polyData = vtkSmartPointer<vtkPolyData>::New();</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> polyData-><span style="font-style:italic">SetPoints</span>(points);</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> polyData->SetVerts(vertices);</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000"> polyData->GetCellData()->SetScalars(colors);</font></span></pre><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 29, 2016 at 7:14 AM, Olivier Rodenberg <span dir="ltr"><<a href="mailto:orodenberg@gmail.com" target="_blank">orodenberg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="NL"><div><p class="MsoNormal">Hi all,</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I am trying to load a point cloud in paraview using a programmable source. I am able to load the points but when assigning a color to each point I get the error message: ‘<span style="font-size:8.5pt;font-family:Courier;color:maroon">AttributeError: 'vtkCommonCorePython.vtkUnsignedCharArray' object has no attribute 'InsertNExtTuple3'</span>. Next is the code I am using:<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><i><span style="color:#7f7f7f">from paraview import vtk<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f">import psycopg2<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f">def connectDBMS():<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> conn = psycopg2.connect("host='localhost' dbname='thesis' user='postgres' password='ww'")<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> cur = conn.cursor() <u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> cur.execute('SELECT x , y , z , red, green, blue FROM pointcloud;') <u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> return cur.fetchall()<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f">def DBMSToGeom(pointcloud): <u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> # Create the points<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> points = vtk.vtkPoints()<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> # create output<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> pdo = self.GetPolyDataOutput()<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> # create color attribute<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> colors = vtk.vtkUnsignedCharArray();<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> colors.SetNumberOfComponents(3);<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> colors.SetName("Color");<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> # loop over the octants in the database<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> for x , y , z , red, green, blue in pointcloud:<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> # create the points<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> points.InsertNextPoint(float(x), float(y), float(z))<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> # create the colors<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> colors.InsertNExtTuple3(int(red), int(green), int(blue));<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> pdo.SetPoints(points)<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> pdo.GetPointData().AddArray(colors)<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> del colors<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f">if (__name__ == "__main__"):<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"> DBMSToGeom(connectDBMS())<u></u><u></u></span></i></p><p class="MsoNormal"><i><span style="color:#7f7f7f"><u></u> <u></u></span></i></p><p class="MsoNormal"><span style="color:black">Does anyone know what I am doing wrong?<u></u><u></u></span></p><p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:black">Thanks in advance,<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888"><p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:black">Olivier</span><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u><u></u></span></p></font></span></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Thales Luis Rodrigues Sabino</div><div><br></div><div>PhD Student at <a href="http://www.ufjf.br/pgmc/" target="_blank">PGMC-UFJF</a></div><div><a href="http://lattes.cnpq.br/0601030410417146" target="_blank">Lattes</a> | <a href="https://br.linkedin.com/in/tluisrs" target="_blank">LinkedIn</a> | <a href="https://www.researchgate.net/profile/Thales_Luis_Sabino" target="_blank">ResearchGate</a></div></div></div></div></div>
</div>