.NET/C# Client#

This guide provides step-by-step instructions for running a Dlubal API client on .NET 9.

Prerequisites#

Before you begin, ensure your system meets the following requirements:

  1. Install the .NET Core SDK (version .NET 9.0 or higher).

    • You’ll need the .NET SDK to install and use NuGet packages in a .NET-based project.

    • Verify the installation by running:

      dotnet --version
      
  2. Install Visual Studio Code as your code editor (for free).

    • Verify the installation by running:

      code --version
      
  3. Install C# Dev Kit extension in VS Code:

    • Open the Extensions view by pressing Ctrl+Shift+X.

    • Search for C# Dev Kit and click Install.

Create a New Project#

  1. Open Visual Studio Code.

  2. Create a New Project with the C# Dev Kit installed:

    • Open the Command Palette by pressing Ctrl+Shift+P

    • Type .NET: New Project... and select it from the list.

    • Choose Console App or another project type from the options.

    • Follow the prompts to select a project template, the target framework, and the location to create the project.

  1. Opening the Project

    • Once the project is created, VS Code will automatically open the folder containing your project, so you can start working directly on it.

Install the Dlubal API Package#

  1. Installing NuGet package from the Terminal (CLI)

    • Open the Terminal in your project directory (press Ctrl+`)

    • Run the following command to install the Dlubal API package into your project.

      dotnet add package Dlubal.Api
      
    • If you need to install a specific version of the package (for example, version 2.10.8), you can do so by appending the --version flag followed by the desired version number:

      dotnet add package Dlubal.Api --version 2.10.8
      

    Important

    The API client version must match the version of your Dlubal application to ensure full compatibility. For example, API client version 2.10.8 corresponds to RFEM 6.10.0008 / RSTAB 9.10.0008.

    Changed in version 2.14.1: The Dlubal.Api NuGet package targets net9.0 instead of net8.0. Projects still targeting net8.0 must either retarget to net9.0, or stay on version 2.13.12 or earlier.

  2. Verify the Installation

    • Run the following command

      dotnet list package
      
    • Ensure Dlubal.Api appears in the list of installed packages.

Using the Package#

using Rfem = Dlubal.Api.Rfem;
using Common = Dlubal.Api.Common;

ApplicationRfem? rfemApp = null;

try
{
   rfemApp = new ApplicationRfem();

   Common.ApplicationInfo appInfo = rfemApp.get_application_info();
   Console.WriteLine(appInfo);

   // Create a new model
   rfemApp.create_model(name: "my_first_model");

   // Create a single node at coordinates [1.0, 2.0, 3.0] (in meters)
   rfemApp.create_object(
      new Rfem.StructureCore.Node
      {
         No = 1,
         Coordinate1 = 1.0,
         Coordinate2 = 2.0,
         Coordinate3 = 3.0
      }
   );
   Console.WriteLine("Created node No. 1.");
}

catch (Exception ex)
{
   Console.WriteLine($"Error: {ex.Message}");
}
finally
{
   if (rfemApp != null) rfemApp.close_connection();
}

For details on API key options and config.ini management, see the Authentication documentation.