Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ifc-cli

ifc-cli is a C++17 command-line tool for reading, editing, tessellating, and saving IFC files through a synchronous JSONL API.

It is built on top of IfcOpenShell and is intended to run as a persistent child process communicating through standard input and output.

Features

  • Load and save IFC files
  • Inspect IFC scene objects
  • Read and update transforms
  • Create additive or subtractive extruded geometry
  • Create and assign materials
  • Read and update property sets
  • Tessellate IFC objects into triangle meshes
  • Communicate through JSON Lines over stdin and stdout

Requirements

Required dependencies:

  • C++17 compiler
  • CMake 3.21 or newer
  • IfcOpenShell with IfcGeom and OpenCascade support
  • Boost
  • Eigen
  • OpenCascade
  • nlohmann/json

Windows

The Windows build uses:

  • Visual Studio 2022 with the Desktop development with C++ workload
  • MSVC x64
  • A Windows SDK
  • A local IfcOpenShell build located in ./IfcOpenShell

IfcOpenShell must be built and installed with the following directories:

IfcOpenShell/_installed-vs2022-x64
IfcOpenShell/_deps-vs2022-x64-installed

The expected IfcOpenShell CMake package is:

IfcOpenShell/_installed-vs2022-x64/lib/cmake/IfcOpenShell/IfcOpenShellConfig.cmake

macOS

Install the dependencies with Homebrew:

brew install cmake ninja boost eigen opencascade nlohmann-json

IfcOpenShell must already be installed. The default installation path is:

$HOME/.local/ifcopenshell

Build

Windows

Run the following commands from Git Bash, a Visual Studio developer shell, or another terminal where CMake and Visual Studio are available:

rm -rf build

cmake \
    -S . \
    -B build \
    -G "Visual Studio 17 2022" \
    -A x64

cmake --build build --config Release --parallel

The executable is generated at:

build/Release/ifc-cli.exe

IfcOpenShell is currently built and installed in Release, so the CLI must also be compiled using the Release configuration.

macOS

cmake \
    -S . \
    -B build \
    -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_PREFIX_PATH="$(brew --prefix)" \
    -DIFCOPENSHELL_ROOT="$HOME/.local/ifcopenshell"

cmake --build build --parallel

The executable is generated at:

build/ifc-cli

Portable release bundles

For reproducible portable Windows x64 and macOS arm64 release builds, see build.md.

Usage

Start the process:

./build/ifc-cli

Each input line must contain one JSON request. Each output line contains one JSON response.

Example:

cat <<'JSONL' | ./build/ifc-cli
{"id":"1","command":"load","params":{"path":"./samples/model.ifc"}}
{"id":"2","command":"transformGetAll","params":{}}
{"id":"3","command":"save","params":{"path":"./samples/model-copy.ifc"}}
{"id":"4","command":"exit","params":{}}
JSONL

Successful response:

{"id":"1","ok":true,"result":{}}

Error response:

{
  "id":"1",
  "ok":false,
  "error":{
    "code":"ERROR_CODE",
    "message":"Error description",
    "details":{}
  }
}

The process keeps the loaded IFC model in memory. All commands operating on a model must therefore be sent to the same process.

API documentation

The functional JSONL API documentation is available in doc.md.

Project structure

ifc-cli/
├── CMakeLists.txt
├── README.md
├── build.md
├── doc.md
├── LICENSE
└── src/
    ├── main.cpp
    ├── protocol.hpp
    ├── scene.hpp
    ├── transform.hpp
    ├── geometry.hpp
    └── material.hpp

License

This project is distributed under the MIT License.

About

Cross-platform C++ CLI for loading, inspecting, editing, and saving IFC models through a synchronous JSON Lines interface powered by IfcOpenShell.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages