Can't run Python script example


#1

I tried to run the ExportPoints.py example and get this error.

Message: ‘file’ object has no attribute ‘writeline’

Thanks Mark


#2

This is an error in translating the script over from vb. There is no “writeline” method in Python.

The section should probably look like this:

 for id in objectIds:
#process point clouds
if( rs.IsPointCloud(id) ):
    points = rs.PointCloudPoints(id)
    for pt in points:
        file.write(str(pt)+"\n")
elif( rs.IsPoint(id) ):
    point = rs.PointCoordinates(id)
    file.write(str(point)+"\n")

The “\n” will put a newline after each point string written. The only problem there is that there will also be a new line at the end of the file - there are workarounds for that if it matters…

HTH, --Mitch


#3

Thanks Mitch

Not something I was missing then.

Mark.