Hey @dale I’m sorry that I have to dig this up but there still seems to be a lot wrong with PointCloud.ClearNormals(), PointCloud.ClearColors() and the setter for PointCloudItem.PointValue as well. I have adapted your test script from youtrack and it gives me the following results:
import Rhino
import scriptcontext as sc
from random import random as rnd
def test_clear_pointcloud_colors():
filter = Rhino.DocObjects.ObjectType.PointSet
rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select pointcloud", False, filter)
if not objref or rc != Rhino.Commands.Result.Success:
return
old_pointcloud = objref.PointCloud()
if not old_pointcloud or not old_pointcloud.ContainsColors:
return
new_pointcloud = Rhino.Geometry.PointCloud(old_pointcloud)
new_pointcloud.ClearColors()
for i, p in enumerate(new_pointcloud):
# this will not work
p.PointValue = rnd()
# this will work, but it will be impossible to get rid of the normals
# without completely rebuilding the cloud
p.Normal = Rhino.Geometry.Vector3d.Unset
# this will print True
print new_pointcloud.ContainsNormals
# this will print True, regardless of ClearColors!
print new_pointcloud.ContainsColors
# attempt to clear the normals
new_pointcloud.ClearNormals()
# this will still print True, regardless of ClearNormals!
print new_pointcloud.ContainsNormals
# this will print False but should print True!
print new_pointcloud.ContainsPointValues
# this will now print False, since ClearNormals actually clears the colors!
print new_pointcloud.ContainsColors
sc.doc.Objects.Replace(objref, new_pointcloud)
sc.doc.Views.Redraw()
if __name__ == "__main__":
I am also attaching your demo/test file to reproduce the errors:
colorful_pointcloud.3dm (43.5 KB)
This is under Rhino Version 7 SR8 (7.8.21196.5001, 2021-07-15)
A fix would be greatly appreciated since this really gets in the way when working with PointClouds 