Runtime

Important

As the functions and types below allow to interact with the CloudCompare app, they are only available in the python embedded within the plugin and not available when using standalone pycc module.

pycc.GetInstance() object

This function returns an object that allows to interact with the running CC instance to get access to already loaded PointCloud and Meshes.

Warning

on command line mode, the object returned will be of type pycc.ccCommandLineInterface.

on gui mode, the object returned will be of type pycc.ccPythonInstance

pycc.GetCmdLineInstance() pycc_runtime.ccCommandLineInterface

Returns the pycc.ccCommandLineInterface object if the script is ran from the command line mode, otherwise returns None.

pycc.GetGUIInstance() pycc_runtime.ccPythonInstance

Returns the pycc.ccPythonInstance object if the script is ran from the command line mode, otherwise returns None.

pycc.InitQApplication() None

Some functions and plugins always need to display GUI dialogs, thus they require an active QApplication. While this is not a problem when in plugin mode as CloudCompare is the QApplication, in stand alone mode it is a problem since CloudCompare is not running.

This function setups a QApplication so that dialogs can be displayed. Does nothing in plugin mode.

class pycc.PythonPluginInterface

The base class for Python plugins.

Every plugin must inherit from this.

import pycc

class MyPlugin(pycc.PythonPluginInterface):
     def __init__(self):
        super().__init__()
getActions(self: pycc_runtime.PythonPluginInterface) std::vector<Runtime::RegisteredPlugin::Action, std::allocator<Runtime::RegisteredPlugin::Action> >

Important

This method. must be implemented

The method shall return the list of actions the plugin can perform. Actions will get added to the context menu of the plugin.

The returned actions must be of type pycc.Action.

getIcon(self: pycc_runtime.PythonPluginInterface) object

It is not mandatory to implement this method.

When implemented, it shall return the icon that shall be used for the plugin sub menu.

see pycc.Action.

class pycc.Action

Represent an action of a plugin.

Parameters:
  • name (str) – The name of the action

  • target – method of the plugin that performs the action

  • icon (optional, either bytes, or tuple[bytes, str] or str default to None) –

    Icon of the action. - If the type is bytes, then they shall the bytes of the icon itself. - If the types is Tuple[bytes, str], then bytes shall be the bytes of the icon

    itself and str the format, e.g. (some_bytes, “PNG”)

    • If str then it shall be the path to a file.

pycc.RunInThread(callable: object, *args, **kwargs) object

Runs the function in a different thread to keep the UI responsive and returns the result of the function when the thread is done.

Example:

import time

def expensive_sum(a, b):
    time.sleep(10)
    return a + b

# if we ran expensive_sum directly, CloudCompare would
# become unresponsive for 10 seconds
result = pycc.RunInThread(expensive_sum, 1, 2)
assert result == 3

ccPythonInstance

class pycc.ccPythonInstance

Class to interact with the running GUI of CloudCompare.

The methods allow you to get/add objects to GUI DB Tree. Refresh/freeze/update the UI and display. Get selected objects, deselect/set selected state for entities…

addToDB(self: pycc_runtime.ccPythonInstance, obj: object, updateZoom: bool = False, autoExpandDBTree: bool = True, checkDimensions: bool = False, autoRedraw: bool = True) None

Adds the object to the GUI DB Tree

app(self: pycc_runtime.ccPythonInstance) pycc_runtime.ccMainAppInterface
dbRootObject(self: pycc_runtime.ccPythonInstance) pycc.ccHObject

Returns the root of the GUI DB Tree

disableAll(self: pycc_runtime.ccPythonInstance) None
enableAll(self: pycc_runtime.ccPythonInstance) None
freezeUI(self: pycc_runtime.ccPythonInstance, state: bool) None
getActiveGLWindow(self: pycc_runtime.ccPythonInstance) pycc.ccGLWindowInterface
getMainWindow(self: pycc_runtime.ccPythonInstance) pycc.QMainWindow
getSelectedEntities(self: pycc_runtime.ccPythonInstance) list[pycc.ccHObject]

Returns the list of selected entities in the GUI DB Tree

haveOneSelection(self: pycc_runtime.ccPythonInstance) bool

Returns True if exactly one entity is selected in the GUI DB Tree

haveSelection(self: pycc_runtime.ccPythonInstance) bool

Returns true if at least one entity is selected in the GUI DB Tree

loadFile(self: pycc_runtime.ccPythonInstance, filepath: str, loadParameters: pycc.FileIOFilter.LoadParameters) pycc.ccHObject

Loads the file located at the filepath.

Adds the file content of the file into the DBTree and then returns loaded object handle.

raises RuntimeError in case of error

redrawAll(self: pycc_runtime.ccPythonInstance, only2D: bool = False) None
refreshAll(self: pycc_runtime.ccPythonInstance, only2D: bool = False) None
removeFromDB(self: pycc_runtime.ccPythonInstance, entity: object) None
setSelectedInDB(self: pycc_runtime.ccPythonInstance, obj: pycc.ccHObject, selected: bool) None

Set the selection state of the object in the GUI DB Tree

updateUI(self: pycc_runtime.ccPythonInstance) None

ccCommandLineInterface

class pycc.ccCommandLineInterface
class ExportOption

Members:

property name
property value
class GlobalShiftOptions
class Mode

Members:

NO_GLOBAL_SHIFT

AUTO_GLOBAL_SHIFT

FIRST_GLOBAL_SHIFT

CUSTOM_GLOBAL_SHIFT

AUTO_GLOBAL_SHIFT = <Mode.AUTO_GLOBAL_SHIFT: 1>
CUSTOM_GLOBAL_SHIFT = <Mode.CUSTOM_GLOBAL_SHIFT: 3>
FIRST_GLOBAL_SHIFT = <Mode.FIRST_GLOBAL_SHIFT: 2>
NO_GLOBAL_SHIFT = <Mode.NO_GLOBAL_SHIFT: 0>
property name
property value
AUTO_GLOBAL_SHIFT = <Mode.AUTO_GLOBAL_SHIFT: 1>
CUSTOM_GLOBAL_SHIFT = <Mode.CUSTOM_GLOBAL_SHIFT: 3>
FIRST_GLOBAL_SHIFT = <Mode.FIRST_GLOBAL_SHIFT: 2>
NO_GLOBAL_SHIFT = <Mode.NO_GLOBAL_SHIFT: 0>
property customGlobalShift
property mode
clouds(self: pycc_runtime.ccCommandLineInterface) pycc_runtime.CLCloudDescVector
exportEntity(self: pycc_runtime.ccCommandLineInterface, entityDesc: pycc_runtime.CLEntityDesc, suffix: QString = '', outputFilename: QString = None, options: QFlags<ccCommandLineInterface::ExportOption> = <ExportOption.???: 0>) QString
getExportFilename(self: pycc_runtime.ccCommandLineInterface, entityDesc: pycc_runtime.CLEntityDesc, extension: QString = '', suffix: QString = '', baseOutputFilename: QString = None, forceNoTimestamp: bool = False) QString
importFile(self: pycc_runtime.ccCommandLineInterface, filename: QString, opts: pycc_runtime.ccCommandLineInterface.GlobalShiftOptions) bool
meshes(self: pycc_runtime.ccCommandLineInterface) pycc_runtime.CLMeshDescVector
saveCloud(self: pycc_runtime.ccCommandLineInterface, suffix: QString = '', allAtOnce: bool = False, allAtOnceFileName: QString = None) bool
saveMeshes(self: pycc_runtime.ccCommandLineInterface, suffix: QString = '', allAtOnce: bool = False, allAtOnceFileName: QString = None) bool