CloudCompare-PythonPlugin icon indicating copy to clipboard operation
CloudCompare-PythonPlugin copied to clipboard

Assign RGB color to polyline, point, mesh

Open mariolino007 opened this issue 5 months ago • 3 comments

hello Thomas,

inside CC 2.13.2, your example to assign color to polyline won’t work....

import pycc
import cccorelib
import numpy as np
CC = pycc.GetInstance()
VERTICES = np.array([
    [-0.5, -0.5, 0],
    [1, 1, 0],
[2, 2, 0]
])
vertices = pycc.ccPointCloud(VERTICES[:, 0], VERTICES[:, 1], VERTICES[:, 2])
polyline = pycc.ccPolyline(vertices)
polyline.setColor(pycc.Rgb(255, 0, 0)) # set the color to red
polyline.showColors(True)
polyline.setClosed(False)
# This is important, otherwise the polyline would have a size of 0
polyline.addPointIndex(0, 3)
CC.addToDB(polyline)
CC.updateUI()
polyline.getDisplay().display3DLabel("Hello, world", cccorelib.CCVector3(1, 1,0))

this is the error:

AttributeError: module 'pycc_runtime' has no attribute 'Rgb'

At:
  <string>(14): <module>

Is possibile to correct the code ? How to assign color to point and mesh ?

thanks Mario

mariolino007 avatar Sep 23 '24 09:09 mariolino007