<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=NL><div class=WordSection1><p class=MsoNormal>Hi all,</p><p class=MsoNormal><o:p> </o:p></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:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'>from paraview import vtk<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'>import psycopg2<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'>def connectDBMS():<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> conn = psycopg2.connect("host='localhost' dbname='thesis' user='postgres' password='ww'")<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> cur = conn.cursor() <o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> cur.execute('SELECT x , y , z , red, green, blue FROM pointcloud;') <o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> return cur.fetchall()<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'>def DBMSToGeom(pointcloud): <o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> # Create the points<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> points = vtk.vtkPoints()<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> # create output<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> pdo = self.GetPolyDataOutput()<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> # create color attribute<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> colors = vtk.vtkUnsignedCharArray();<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> colors.SetNumberOfComponents(3);<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> colors.SetName("Color");<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> # loop over the octants in the database<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> for x , y , z , red, green, blue in pointcloud:<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> # create the points<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> points.InsertNextPoint(float(x), float(y), float(z))<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> # create the colors<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> colors.InsertNExtTuple3(int(red), int(green), int(blue));<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> pdo.SetPoints(points)<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> pdo.GetPointData().AddArray(colors)<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> del colors<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'>if (__name__ == "__main__"):<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'> DBMSToGeom(connectDBMS())<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%'><o:p> </o:p></span></i></p><p class=MsoNormal><span style='color:black'>Does anyone know what I am doing wrong?<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:black'>Thanks in advance,<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:black'>Olivier</span><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p></o:p></span></p></div></body></html>