Although MeshLib is written in C++, all its functions are also exposed to Python. Python code can be executed from within a MeshLib-based C++ application (embedded mode) or directly from a Python interpreter, which imports MeshLib modules.
Moreover, using a pip package manager, MeshLib can be easily installed as a Python 3.8 – 3.11 package.
First, you might need to upgrade your pip version to the latest one. For that purpose, run the following command:
On Windows/MacOS
python -m pip install –upgrade pip
On Linux
Supporting manylinux_2_31+, including Ubuntu 20+ and Fedora 32+
sudo apt install python3-pip
python3 -m pip install –upgrade pip
Then run this command to install the latest MeshLib.
On Windows/Linux/MacOS:
python -m pip install meshlib
If you wish to install a specific version, you can use this command:
On Windows/Linux/MacOS
python -m pip install meshlib==2.1.6
To check MeshLib version installed on your PC run this command:
On Windows/Linux/MacOS:
python -m pip show meshlib
When the MeshLib package is installed, you can call any of its functions. Let’s give a simple example of how to open a .stl file and then save it as .ply:
import meshlib.mrmeshpy as mrmeshpy
mesh = mrmeshpy.loadMesh(mrmeshpy.Path(“c://model.stl”))
mrmeshpy.saveMesh(mesh, mrmeshpy.Path(“c://model.ply”))