Automatically open clouds generated in Python

Feel free to ask any question here
Post Reply
djdan7
Posts: 2
Joined: Mon Nov 13, 2023 8:49 am

Automatically open clouds generated in Python

Post by djdan7 »

This is my first post, so hello everyone! :D

I generate point clouds in Python. I can save them in different formats, but generally they are a numpy matrices [x,y,z,r,g,b,intensity]. Then I would like to open them automatically in the CloudCompare window, without manually clicking open -> point to file -> apply all -> global shift -> yes ->..., or manually dragging files from windows explorer to the CC window. Is it possible to load files into the CC window directly from the Python script? For now, I only need to display these clouds in a window for viewing.

I managed to run CC automatically from Python, but I don't know what to do next:

Code: Select all

import os

path = 'c:/Program Files/CloudCompare/CloudCompare.exe'

print('opening CC')
os.system('"%s"' % path)
Thank you for any suggestions :)
daniel
Site Admin
Posts: 7383
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Automatically open clouds generated in Python

Post by daniel »

You really just have to type 'CloudCompare your_file_name.ext' to load a file automatically.

But if the format requires a dialog to appear, this dialog will appear anyway...
Daniel, CloudCompare admin
djdan7
Posts: 2
Joined: Mon Nov 13, 2023 8:49 am

Re: Automatically open clouds generated in Python

Post by djdan7 »

EDIT:
Ok, I got it. This code opens the program with given 2 point clouds

Code: Select all

path = '"c:/Program Files/CloudCompare/CloudCompare.exe" "c:/DATA/LA010001nn_n_2000.pts" "c:/DATA/LA010002nn_n_2000.pts"'
print('opening CC')
os.system('"%s"' % path)
The problem is that with this approach I cannot use commands from https://www.cloudcompare.org/doc/wiki/i ... _line_mode, because some errors appears. And also there is second challenge, how I can open more clouds after some time (not only at the beginning with program opening)?

Thank you for help!
daniel
Site Admin
Posts: 7383
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Automatically open clouds generated in Python

Post by daniel »

Ah indeed, that's much more advanced. Maybe you could take a look at the QJson RPC plugin (see https://gitlab.com/theadib/JSonRPCPlugin)
Daniel, CloudCompare admin
Post Reply