Hi,
I run a short python script to split a large point cloud into two point clouds using a surface. After the large point cloud is split, i then make each individual point cloud a different color.
This worked in Rhino6, but for some reason it doesn’t work in Rhino8. In Rhino8, after running the script, the points in the point cloud just remain black no matter what color i apply to them. I even tried doing “Explode” and then “Create Point Cloud” to try to reset the point clouds to get them to accept a color. Not sure why that didn’t work.
Any ideas? Thanks in advance.
Here’s my sort python script:
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
def test():
ptId = rs.GetObject("Select the point cloud",2, preselect=True)
if not ptId:return
srfId = rs.GetObject("Select the surface",8, preselect=True)
if not srfId:return
face = sc.doc.Objects.Find(srfId).Geometry.Faces[0]
srf = face.ToNurbsSurface()
ptCl = sc.doc.Objects.Find(ptId).Geometry
PC1 = Rhino.Geometry.PointCloud()
PC2 = Rhino.Geometry.PointCloud()
n = 0
m = 0
for item in ptCl:
pt = item.Location
color = item.Color
par = srf.ClosestPoint(pt)
vecNorm = srf.NormalAt(par[1], par[2])
srfPt = srf.PointAt(par[1], par[2])
vecDir = pt-srfPt
vecDir.Unitize()
vecDir.IsParallelTo(vecNorm)
if vecDir.IsParallelTo(vecNorm) == -1:
PC1.Add(pt, color)
n = n + 1
else:
PC2.Add(pt, color)
m = m + 1
if n>0: sc.doc.Objects.AddPointCloud(PC1)
if m>0: sc.doc.Objects.AddPointCloud(PC2)
sc.doc.Objects.Delete(ptId, False)
pass
if name == “main”:
test()
3 posts - 2 participants