Loading [MathJax]/extensions/tex2jax.js
MeshLib Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Integrating MeshLib with C#

Using MeshLib with C#

This instruction will guide you through integrating MeshLib into your C# project using NuGet or the .NET Command-Line Interface.

Note
We are planning to deliver full C# support in 2025. Until then, only the core features of MeshLib are available in C#, and the API may evolve as we expand functionality. We will strive to minimize disruptions and ensure a smooth transition as these changes are introduced.
C# integration is currently supported on Windows x64 and Linux x64. Please note that ARM64 builds are not yet available, so make sure your project is configured accordingly to avoid compatibility issues.

Prerequisites

Before installing MeshLib, ensure you have the following tools installed:

.NET SDK

  • Install the latest version of the .NET SDK from the .NET website. MeshLib is compatible with .NET Framework 4.7 and higher, as well as .NET 5.0, 6.0, 7.0, 8.0, and additional versions outlined below.
  • Verify your installation by running:
    dotnet --version

Visual Studio

For a more integrated development experience, you can use Visual Studio 2019 or later. Make sure to install the **.NET desktop development** workload.

Installation via NuGet

Depending on your development environment and workflow preferences, you can choose from the following installation methods

Using Visual Studio on Windows

To install MeshLib via Visual Studio, follow these steps:

  1. Open Your Project in Visual Studio:
    • If you don’t have a project yet, create a new C# Console App (.NET Core) or another suitable project type.
  2. Open the NuGet Package Manager:
    • Right-click on your project in the Solution Explorer.
    • Select "Manage NuGet Packages."
  3. Search for MeshLib:
    • In the NuGet Package Manager, switch to the "Browse" tab.
    • Enter "MeshLib" in the search box.
  4. Install the Package:
    • Select the MeshLib package from the search results.
    • Click "Install" and follow any prompts to complete the installation.
  5. Start Using MeshLib:
    • Add using static MR.DotNet; at the top of your C# files to start using MeshLib features.

Installation from a Downloaded NuGet Package

If you prefer to download the MeshLib package directly from the NuGet website, follow these steps:

  1. Download the MeshLib Package:
  2. Create a Local Directory for NuGet Packages:
    • Choose or create a directory on your system where you will store the .nupkg file. For example:
      mkdir ~/LocalNuGetPackages
    • Move the downloaded MeshLib.nupkg file to this directory.
  3. Install the MeshLib Package Locally:
    • Use the command below to install the package:
      dotnet add package MeshLib --source /path/to/LocalNuGetPackages
  4. Alternative: Configure Local Source Globally:
    • Add the local directory as a source using:
      dotnet nuget add source \path\to\LocalNuGetPackages --name LocalPackages
    • After this, you can install the package normally without specifying -source.
  5. Build and Run Your Project:
    dotnet build
    dotnet run

Installation via .NET Command-Line Interface

To install MeshLib via the .NET CLI, follow these steps:

  1. Open a Terminal or Command Prompt:
    • On Windows, use Command Prompt, PowerShell, or the Windows Terminal.
  2. Create a New Project Directory:
    Run the following commands to create a new directory for your project and navigate into it:
    mkdir TestProject
    cd TestProject
  3. Create a New .NET Console Project:
    Inside the new directory, initialize a .NET console project by running:
    dotnet new console
  4. Install the MeshLib Package:
    Use the following command to add MeshLib to your project:
    dotnet add package MeshLib
  5. Build and Run Your Project:
    After installing MeshLib, you can build and run your project using:
    dotnet run

By following these steps, you can integrate MeshLib into your project, giving you more control over the setup process.

Try MeshLib with C# Examples

MeshLib provides a collection of C# code samples to help you get started quickly with common mesh processing tasks. These are concise, self-contained examples — perfect for exploring how to use MeshLib’s API in your own projects:

  • Load and Save Meshes Demonstrates how to load and export mesh files using the MeshLib API.
  • Mesh Boolean Operations Shows how to perform boolean operations like union, intersection, and subtraction between meshes.
  • Mesh Simplification Illustrates how to reduce mesh complexity through decimation, preserving overall shape with fewer polygons.

These samples are a great starting point for integrating MeshLib into C# or .NET-based workflow.