<div dir="ltr">It's a simple capitalization error<div><br></div><div><span style="color:rgb(128,0,0);font-family:Courier;font-size:11.3333px">InsertNExtTuple3 -> InsertNextTuple3</span><br></div><div><span style="color:rgb(128,0,0);font-family:Courier;font-size:11.3333px"><br></span></div>Notice the upper case 'E' in your code.<div><br></div><div>The Python wrappers have improved in recent years, so you should be able to call</div><div><br></div><div><i style="font-size:12.8px"><span style="color:rgb(127,127,127)">colors.InsertNExtTuple3([int(red), int(green), int(blue)]);</span></i><br></div><div><i style="font-size:12.8px"><span style="color:rgb(127,127,127)"><br></span></i></div>Note the arguments have been placed in a list here. I think a tuple should work, too.<div><br></div><div>HTH,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 29, 2016 at 4: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">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>