COLNEO Pro 1.0
Loading...
Searching...
No Matches
ProjectAPI

Description

Project API interface.

Register Javascript object with cnProjectAPI.

The Project API provides project related information and functions such as getting/setting project informations, settings, connection to COLNEO infohub project, opening and saving project etc.

Since
1.0, 10.2025

Functions

PROJECT INFO
ApiJsonResponse getInfo (QStringList keys=QStringList())
 
ApiJsonResponse getDirectory ()
 
ApiJsonResponse setInfo (QVariantMap &projectInfo)
 
ApiJsonResponse getInfohubSettings ()
 
ApiJsonResponse setInfohubSettings (QVariantMap &settings)
 
ApiJsonResponse getStatistics ()
 
PROJECT
ApiJsonResponse create (QVariantMap settings)
 
ApiJsonResponse open (QString filepath)
 
ApiJsonResponse saveAs (QString &filepath)
 
ApiJsonResponse archive (QString &filepath)
 
ApiJsonResponse close ()
 
MODELS
ApiJsonResponse importModel (QString &filepath, QVariantMap &importOptions=QVariantMap())
 
ApiJsonResponse exportModels (QString &filePath, QStringList &modelIds, QVariantMap &options)
 
MACROS
ApiJsonResponse getMacroIds ()
 
ApiJsonResponse getMacro (QString &id)
 
ApiJsonResponse createMacro (QVariantMap &macroAsJson)
 
ApiJsonResponse updateMacro (QString &id, QVariantMap &macroAsJson)
 
ApiJsonResponse deleteMacro (QString &id)
 
ApiJsonResponse runMacro (QString &id)
 

Function Documentation

◆ archive

ApiJsonResponse archive ( QString & filepath)
slot

Creates a project archive (zip).

Parameters
filepath
Returns
{
data: ...
}
Since
1.0.0

◆ close

ApiJsonResponse close ( )
slot

Closes the current project without confirmation. Handle with care!

Returns
{
data: void
}

◆ create

ApiJsonResponse create ( QVariantMap settings)
slot

Create a new, empty project.

Parameters
settings
{
name: "",
code: "",
description: ""
}
Returns
Since
1.0

◆ createMacro

ApiJsonResponse createMacro ( QVariantMap & macroAsJson)
slot

Create a new macro. If no ID is specified, it is generated automatically.

Parameters
macroAsJsonObject holding the data
{
name: "MyMacro",
desc: "Set all object visible in domain design",
code: "cnCoreAPI.setVisibleAll(true, \"geo\")",
actionName: ""
}
Returns
ID of new macro
data : string
Since
1.0, May 2025

◆ deleteMacro

ApiJsonResponse deleteMacro ( QString & id)
slot

...

Parameters
id
Since
1.0.0, ...

◆ exportModels

ApiJsonResponse exportModels ( QString & filePath,
QStringList & modelIds,
QVariantMap & options )
slot

Exports one or more models to a file in either JSON (.cnjson) or binary (.cnbin) format.

Parameters
filePathAbsolute path to the target file, e.g. "C:/MyModels/Test.cnjson".
modelIdsList of model IDs to export. Only valid model IDs are processed, invalid or non-model IDs are ignored.
optionsExport configuration. If a section key (e.g. "geometry", "properties", "nodes") is missing or explicitly set to null, that category will not be exported.
{
"geometry" : {
"fields": ["vertices", "triangles", "faces", "facets", "styles", "edges"],
"whitelist": true
},
"properties": {
"propertytypes" : ["cnName##xs:string", "cnGuid##xs:ID"],
"whitelist": false,
"typed_properties": false // unused for now
},
"nodes": {
"exclude_hidden": false,
"exclude_openings": true,
"exclude_assembly_parts": false
},
...
}
Returns
data: Array<string> // List of model IDs sucessfully exported.
Since
1.0, Oct 2025

◆ getDirectory

ApiJsonResponse getDirectory ( )
slot

Gets the directory of the current project.

Usable in scripted properties

Returns
Absolute path of the project directory.
data: string
Since
1.0, Dec 2025

◆ getInfo

ApiJsonResponse getInfo ( QStringList keys = QStringList())
slot

Usable in scripted properties

Get project information such as name, ID, created by etc. Also get information about connection to COLNEO infohub.

Parameters
keysIf specified, only the corresponding keys/attributes are returned, otherwise the entire project data.
Returns
data : {
"filePath": "C:/Documents/COLNEO Projects/Test/test.cnp",
"id": "",
"name" : "Test",
"shortDescription" : "",
"createdBy": "max@colneo.email",
"createdOn": "2025-04-09T08:41:17.054Z",
"description": "Test Project",
"executionPeriod": "",
"savedBy": "max@colneo.email",
"savedOn": "2025-04-09T08:41:17.055Z",
"savedWithVersion": "1.0.0",
"properties" : {
"budget##xs:double" : 0.0,
"client##xs:string" : " ... ",
"project:number##xs:string" : "",
"project:phase##xs:string" : "",
},
"infohub" : {
"scope_id" : " ... ",
"project_shortid" : " ... ",
"connected_by" : " ... "
}
}
See also
getDirectory()
Since
1.0, Jul 2025

◆ getInfohubSettings

ApiJsonResponse getInfohubSettings ( )
slot

Usable in scripted properties

Get infohub settings such as scope and project short id which stores the connection between the local COLNEO pro project and a project on infohub.

Returns
data : {
"scope_id" : "...",
"project_shortid" : "...",
"connected_by" : "..."
}
Since
1.0, Sep 2025, jh

◆ getMacro

ApiJsonResponse getMacro ( QString & id)
slot

Get macro data with specified ID.

Parameters
idID of macro.
Returns
{
id: "",
name: "",
desc: "",
code: "",
actionName: ""
}
Since
1.0, May 2025

◆ getMacroIds

ApiJsonResponse getMacroIds ( )
slot

Get IDs of available macros in project.

Returns
List of macro IDs.
data : Array<string>
Since
1.0, May 2025

◆ getStatistics

ApiJsonResponse getStatistics ( )
slot

...

Returns
{
key: value
}
Since
1.0.0

◆ importModel

ApiJsonResponse importModel ( QString & filepath,
QVariantMap & importOptions = QVariantMap() )
slot

Import a model from file. Currenty supported file formats are .ifc, ifcxml, .ifczip, .cpixml, .cnjson or .cnbin.

Parameters
filepathThe file path of the model file, e.g "C:/MyModels/Test.ifc"
importOptionsImport options
{
"base": {
"updateStyles": true,
},
"design":{
"translation": [400.0, -20.0, 0],
"rotation_point": [0.0, 0.0],
"rotation_angle": 30.0,
"scaling": [1.0, 1.0, 1.0]
}
...
}
Returns
ID of imported model, else empty string if an error occured.
data: string
Since
1.0, May 2025

◆ open

ApiJsonResponse open ( QString filepath)
slot

Open the project from a given file path.

Parameters
filepath
Returns
true, if project was opened successful, otherwise false
{
key: value
}
Since
1.0

◆ runMacro

ApiJsonResponse runMacro ( QString & id)
slot

Run (evaluates) a macro

Parameters
idID of macro.
Returns
Result of evaluation
Since
1.0.0, 2025-02-05

◆ saveAs

ApiJsonResponse saveAs ( QString & filepath)
slot

Saves the project under the current file path.

Returns
{
key: value
}
\since 1.0.0
/
/*!
Saves the project under a new file path.
\param filepath
\returns
\code
{
data: boolean
}
Since
1.0.0

◆ setInfo

ApiJsonResponse setInfo ( QVariantMap & projectInfo)
slot

Set Project Information.

Returns
{
data:
}
Since
1.0.0

◆ setInfohubSettings

ApiJsonResponse setInfohubSettings ( QVariantMap & settings)
slot

Set infohub settings such as scope and project shortid.
Keys are set partially, only the given keys are changed.

Parameters
settings
{
"scope_id" : "...",
"project_shortid" : "...",
"connected_by" : "..."
}
Returns
true if setting was successfully, else false
data: boolean
Since
1.0, Sep 2025, jh

◆ updateMacro

ApiJsonResponse updateMacro ( QString & id,
QVariantMap & macroAsJson )
slot

Update a macro. The ID cannot be changed!

Parameters
id
macroAsJson
Returns
True, if macro was updated (changed!) successfully
data : boolean
See also
createMacro()
Since
1.0, May 2025