[v6] No colors for Point Clouds?

v6

(Przemysław Doliwa) #1

I have trouble with colored point clouds which worked perfectly in v5.

http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_PointCloud_Add_3.htm

This seems not working. In v5 i have colorful clouds in v6 only black.

Rhino ver. (6.2.18051.9541, 20.02.2018)

This method also doesn’t work: http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_PointCloud_Add_2.htm


(Dale Fugier) #2

Hi @D-W,

This seems to work in V6:

import Rhino
import System
import scriptcontext as sc

def RandomPoint(center, radius, rnd):
    angle = 2.0 * System.Math.PI * rnd.NextDouble()
    x = center.X + radius * System.Math.Cos(angle)
    y = center.Y + radius * System.Math.Sin(angle)
    return Rhino.Geometry.Point3d(x, y, 0.0)

def RandomColor(rnd):
    return System.Drawing.Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256))
    
def TestPointCloud():
    rnd = System.Random()
    pc = Rhino.Geometry.PointCloud()
    center = Rhino.Geometry.Point3d.Origin
    radius = 4
    count = 100
    i = 0
    
    while i < count:
        pt = RandomPoint(center, radius, rnd)
        clr = RandomColor(rnd)
        pc.Add(pt, clr)
        i += 1
    
    sc.doc.Objects.AddPointCloud(pc)
    sc.doc.Views.Redraw()
    
TestPointCloud()

Perhaps we need to see some code that is not working for you?


(Przemysław Doliwa) #3

@dale Unfortunately i can’t disclose code but even simple example like this don’t work:

            pCld = new PointCloud();
            xSize = 10;

            for (int x = 0; x <= xSize; x++)
                {
                    pCld.Add(new Point3d(x * xSize, 0, 0), Color.Orange);
                }

/// Further in post draw override

            if (pCld != null)
                    e.Display.DrawPointCloud(pCld, 3);

Two things to mention: first i’m on vs2015 with v5 rhinocommon but v6 shows plug is ok:
"Compatibility test succeeded in 0.43s"
second i don’t put things to doc cause i need this only for viewing purposes


(Przemysław Doliwa) #4

@dale Any ideas? Shouldn’t this be also compatible?


(Dale Fugier) #5

Hi @D-W,

Sorry, I was sleeping.

I am able to reproduce the conduit drawing bug. I’ve logged the issue - you can track it here.

https://mcneel.myjetbrains.com/youtrack/issue/RH-44457

That said, DisplayPipeline.DrawPointCloud eventually just calls DisplayPipeline.DrawPoint for each point in the point cloud. You can do the same to work around this issue.

– Dale


(Przemysław Doliwa) #6

@dale That means theres no point to push list of points to cloud? I need performance here so im wondering what is better - pushing points to cloud and viewing single cloud or just pushing list of points to DisplayPipeline.DrawPoint directly cause i’m saving memory so far i’ve discovered that rhino behaves better when viewing 1 milion points in cloud then as individual objects but as i assume this probably relates only to doc objects? @dale could you ensure me on this?


(Steve Baer) #7

I will fix this issue very soon. Using a point cloud for drawing will perform better. Dale gave you a solution that will work today.


(Brian Gillespie) #8

RH-44457 is fixed in the latest Service Release Candidate