I tried to script in python a split pointcloud option by using a minimum and maximum box coordinate.
In comparison with the standard rhino remove from pointcloud option it is very slow.
Is there a way to use this command in a python script? or is there another way in python to split a big pointcloud. The size of the pointcloud is 21102488 points.
In my opinion it is the best to go one time through the whole pointcloud with a list of box coordinates and than to replace and add the new pointclouds at ones.
import Rhino
import copy
import rhinoscriptsyntax as rs
import scriptcontext as sc
def DeletePointCloudPoints(cloud, minpt, maxpt):
cloud=rs.coercegeometry(cloud)
pts = Rhino.Collections.Point3dList(cloud.GetPoints())
pln = Rhino.Geometry.Plane.WorldXY
pln.Origin = Rhino.Geometry.Point3d(rs.coerce3dpoint(minpt))
r3d = Rhino.Geometry.Rectangle3d(pln, maxpt[0]-minpt[0],maxpt[1]-minpt[1])
pci = Rhino.Geometry.PointContainment.Inside
idx=[]
idy=[]
for i,pt in enumerate(pts):
if r3d.Contains(pt) == pci:idx.append(i)
else: idy.append(i)
idx = [i for i, pt in enumerate(pts) if r3d.Contains(pt) == pci]
if idx.Count > 0:
cloud1=copy.deepcopy(cloud)
cloud.RemoveRange(idx)
cloud1.RemoveRange(idy)
return cloud,cloud1
cloud=rs.GetObject('cloud',3)
minpt=[153758,-23000,0]
maxpt=[154758,5000,0]
cloudoud,cloudnew=DeletePointCloudPoints(cloud,minpt,maxpt)
sc.doc.ActiveDoc.Objects.AddPointCloud(cloudnew)
sc.doc.ActiveDoc.Objects.Replace(cloud,cloudoud)
sc.doc.Views.Redraw()