Eriksson Beam API
Search Results for

    Show / Hide Table of Contents

    First Connection

    This guide walks you through connecting to Eriksson Beam and performing your first data operations. By the end, you'll have a working console application that pulls data, modifies it, and pushes changes back.

    Complete Example

    Here's a complete, working example:

    using System;
    using System.Threading.Tasks;
    using ErikssonBeam.API.BeamClient;
    using ErikssonBeam.API.BeamDesigner;
    
    class Program
    {
        static async Task Main(string[] args)
        {
            // Configuration
            var licenseKey = Environment.GetEnvironmentVariable("ERIKSSON_LICENSE_KEY");
            var executablePath = @"C:\Program Files\Eriksson Software\Eriksson Beam\ErikssonBeam.exe";
            var projectFile = @"C:\Projects\MyBeam.ebf";
    
            // Set up launcher arguments
            var launcherArgs = new ErikssonBeamLauncherArgs
            {
                LicenseKey = licenseKey,
                ExecutablePath = executablePath,
                FilesToOpen = new[] { projectFile },
                CloseErikssonBeamOnClientDisconnect = true,
                IdleTimeoutMs = 30000
            };
    
            // Launch Eriksson Beam and get a client
            using (var launcher = await ErikssonBeamLauncher.LaunchErikssonBeam(launcherArgs))
            {
                var client = launcher.Client;
    
                // Pull the current beam design
                var design = await client.PullBeamDesignerAsync();
    
                // Display current values
                Console.WriteLine($"Project: {design.DesignCriteria.ProjectInformation.ProjectName}");
                Console.WriteLine($"Designer: {design.DesignCriteria.ProjectInformation.DesignerName}");
    
                // Modify some values
                design.DesignCriteria.ProjectInformation.DesignerName = "Updated via API";
                design.DesignCriteria.ProjectInformation.Date = DateTime.Now;
    
                // Push changes back to Eriksson Beam
                await client.PushBeamDesignerAsync("", design);
    
                Console.WriteLine("Changes pushed successfully!");
            }
            // Eriksson Beam closes automatically when launcher is disposed
        }
    }
    

    Step-by-Step Breakdown

    1. Configure Your Environment

    var licenseKey = Environment.GetEnvironmentVariable("ERIKSSON_LICENSE_KEY");
    var executablePath = @"C:\Program Files\Eriksson Software\Eriksson Beam\ErikssonBeam.exe";
    var projectFile = @"C:\Projects\MyBeam.ebf";
    
    • License Key: Stored in an environment variable for security
    • Executable Path: Full path to ErikssonBeam.exe
    • Project File: Path to a .ebf file to open

    2. Set Up Launcher Arguments

    var launcherArgs = new ErikssonBeamLauncherArgs
    {
        LicenseKey = licenseKey,
        ExecutablePath = executablePath,
        FilesToOpen = new[] { projectFile },
        CloseErikssonBeamOnClientDisconnect = true,
        IdleTimeoutMs = 30000
    };
    
    Property Description
    LicenseKey Your API authorization key
    ExecutablePath Path to ErikssonBeam.exe
    FilesToOpen Array of project files to open on launch
    CloseErikssonBeamOnClientDisconnect Auto-close Eriksson Beam when done
    IdleTimeoutMs Connection timeout in milliseconds

    3. Launch and Connect

    using (var launcher = await ErikssonBeamLauncher.LaunchErikssonBeam(launcherArgs))
    {
        var client = launcher.Client;
        // ...
    }
    

    The using statement ensures proper cleanup. When the launcher is disposed:

    • The client connection is closed
    • Eriksson Beam closes (if CloseErikssonBeamOnClientDisconnect is true)

    4. Pull Data

    var design = await client.PullBeamDesignerAsync();
    

    This retrieves a BeamDesign object containing all input data from the currently open project.

    5. Modify Data

    design.DesignCriteria.ProjectInformation.DesignerName = "Updated via API";
    design.DesignCriteria.ProjectInformation.Date = DateTime.Now;
    

    Access and modify properties through the BeamDesign hierarchy.

    6. Push Changes

    await client.PushBeamDesignerAsync("", design);
    

    Push the modified design back. The empty string "" targets the single open project.

    Alternative: Connect to Running Instance

    If Eriksson Beam is already running, connect without launching:

    var connectionArgs = new ErikssonBeamConnectionAttemptArgs
    {
        LicenseKey = licenseKey,
        MaxAttempts = 10,
        WaitTimeBetweenAttemptsMs = 1000
    };
    
    // Find any running instance
    var client = await ErikssonBeamFinder.GetFirstSupportedBeamClient(connectionArgs);
    
    try
    {
        var design = await client.PullBeamDesignerAsync();
        // Work with design...
    }
    finally
    {
        client.Dispose();
    }
    

    Important: Eriksson Beam only listens for API connections for 10 minutes after launch. If you can't connect, restart Eriksson Beam.

    Common Patterns

    Batch All Changes Before Pushing

    Pushes are expensive operations. Always batch modifications:

    // DO: Batch changes
    design.DesignCriteria.ProjectInformation.DesignerName = "Jane Doe";
    design.DesignCriteria.ProjectInformation.ClientName = "ACME Corp";
    design.DesignCriteria.ProjectInformation.Date = DateTime.Now;
    design.StructuralModel.Loading.SelfWeightMultiplier = 1.2;
    await client.PushBeamDesignerAsync("", design);  // One push
    
    // DON'T: Push after each change
    design.DesignCriteria.ProjectInformation.DesignerName = "Jane Doe";
    await client.PushBeamDesignerAsync("", design);  // Slow!
    design.DesignCriteria.ProjectInformation.ClientName = "ACME Corp";
    await client.PushBeamDesignerAsync("", design);  // Slower!
    

    Always Pull Before Modifying

    Never create a BeamDesign directly. Always pull first to preserve existing data:

    // DO: Pull first
    var design = await client.PullBeamDesignerAsync();
    design.DesignCriteria.ProjectInformation.DesignerName = "Jane Doe";
    await client.PushBeamDesignerAsync("", design);
    
    // DON'T: Create directly (causes data loss!)
    var design = new BeamDesign();  // All fields are default values!
    design.DesignCriteria.ProjectInformation.DesignerName = "Jane Doe";
    await client.PushBeamDesignerAsync("", design);  // Overwrites ALL fields!
    

    Next Steps

    • Learn about all Connection Methods
    • Understand the Data Model
    • Review Best Practices
    • Edit this page
    In this article
    Back to top Generated by DocFX