tmontaigu / CloudCompare-PythonRuntime

Python plugin for CloudCompare
55 stars 15 forks source link

Assign RGB color to polyline, point, mesh #125

Open mariolino007 opened 2 months ago

mariolino007 commented 2 months ago

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

tmontaigu commented 1 month ago

Yes that is normal because the python runtime that is within CloudCompare 2.13 is old and does not have these functions

mariolino007 commented 1 month ago

verified with 2.14 built 29/9/2024 the error persist

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

At:

(14): Error
tmontaigu commented 1 month ago

Hum that is because the version of the python runtime that is is CC's installer is also too old

Maybe you could try using the installer that is linked in the readme

mariolino007 commented 1 month ago

there is something like this

import sys print(sys.version) import platform print(platform.python_version())

to check the python runtime version ?

I need to be able to assign RGB color to points, polyline and mesh, possibly I will open a request to daniel on CC forum for a make a new build with updated python runtime environment....

tmontaigu commented 3 weeks ago

No there is no way to check the version of the CloudCompare python bindings

mariolino007 commented 2 weeks ago

unfortunately not even in the latest version of CC (2.14.alpha 10/14/2024) the script for the color wont works, how can I solve the problem ? What can I ask Daniel to get the correct version of CloudCompare-PythonRuntime implemented ? Can I ask you if you are sure that the part of your code on this aspect is correct can you verify it ?

Thanks

tmontaigu commented 1 week ago

I'll verify

mariolino007 commented 1 week ago

Unfortunately, it does not work even in version 2.14 of 04/11/2024...

tmontaigu commented 1 week ago

Yes because it seems its still not using the latest version of the runtime

What you can do is download the runtime installer from here https://u.pcloud.link/publink/show?code=XZlNs00Z5koREF3zkzSSFRmBs9tQUFj5Cq97 and use it to install the latest version (you may have to first run it to uninstall the current version first then re-run it to install)

dgirardeau commented 4 days ago

Is the latest version of the runtime compatible with the latest 'sf_double' branch? I'm mostly waiting for this plugin to work with this branch to merge and update everything...

tmontaigu commented 4 days ago

I'll do it this week end

tmontaigu commented 19 hours ago

I have this double-sf it compiles and works, but it needs a bit more work to be more robust and also some tests

dgirardeau commented 19 hours ago

Thanks. Can I still issue a new 'alpha' release or should I wait a little bit more?

tmontaigu commented 3 hours ago

Should wait that I confirm there is no trivial bug