Getting Started with .NET

Prerequisites

Create a .NET project

Open a terminal, and run the following command:

dotnet new console --output ParagonApiGettingStarted

This will create a new console app in the ParagonApiGettingStarted directory.

Install the Paragon API Nuget Package

Run the following commands:

cd ParagonApiGettingStarted
dotnet add package ParagonApi

This navigates to the project directory and adds the ParagonApi Nuget package to the project.

Add sample code

Replace the contents of Program.cs withing the ParagonApiGettingStarted directory with the following code:

using ParagonApi;
using ParagonApi.Models;

Console.WriteLine("Connecting to the Paragon API...");
using var connection = await Paragon.Connect();

Console.WriteLine("Creating a new project...");
var project = await connection.Projects.Create(new Project { Name = "Test API Project" });

Console.WriteLine("Creating a new truss...");
var truss = await connection.Trusses.CreateProfileTruss(
    project.Guid,
    new Profile
    {
        Name = "RT-1",
        TopChordPoints =
        [
            new Point2D { X = 0, Y = 4.163118960624631 },
            new Point2D { X = 144, Y = 76.1631189606246 },
            new Point2D { X = 288, Y = 4.163118960624631 },
        ],
        BottomChordPoints = [new Point2D { X = 0, Y = 0 }, new Point2D { X = 288, Y = 0 }],
        LeftOverhang = new Overhang { Distance = 24 },
        RightOverhang = new Overhang { Distance = 24 },
    }
);

Console.WriteLine($"Upgrading and analyzing {truss.Name}...");
var analysisSet = await connection.Trusses.UpgradeAndAnalyze(truss.Guid);
Console.WriteLine($"Capacity Ratio: {analysisSet.CapacityRatio}");

Console.WriteLine($"Project URL: https://design.paragontruss.com/{project.Guid}");

Run the project

Run the following command:

dotnet run

It should produce the following output:

Connecting to the Paragon API...

If this is your first time using the Paragon API, the app will open your default web browser to the Paragon Services client and you will be presented with an option to authorize:

If your account is set up properly you should get a success message:

Now when you go back to your terminal you should see the following output indicating that a project has been created successfully.

Creating a new project...
Creating a new truss...
Upgrading and analyzing RT-1...
Capacity Ratio: 0.96
Project URL: https://design.paragontruss.com/b6c08e19-686f-4a25-8e6f-0a3ca37377b2

View truss

Open the project URL that was outputted in the last step in a browser to see the truss that was created:

Additional Resources

Last updated