Eriksson Beam API
Search Results for

    Show / Hide Table of Contents

    Project Management

    File operations for managing beam projects: listing, saving, and creating files.

    Available Operations

    Method Description
    GetOpenBeamProjects List currently open project files
    SaveProject Save a project to disk
    CreateProjects Create new blank project files

    Listing Open Projects

    string[] openProjects = await client.GetOpenBeamProjects();
    
    foreach (var project in openProjects)
    {
        Console.WriteLine($"Open: {project}");
    }
    

    Method Signature

    public async Task<string[]> GetOpenBeamProjects()
    

    Returns

    Array of project identifiers (file names or paths) for all currently open projects.

    Example

    var projects = await client.GetOpenBeamProjects();
    
    if (projects.Length == 0)
    {
        Console.WriteLine("No projects open");
    }
    else if (projects.Length == 1)
    {
        // Can use empty string for pull/push
        var design = await client.PullBeamDesignerAsync();
    }
    else
    {
        // Must specify which project
        foreach (var project in projects)
        {
            var design = await client.PullBeamDesignerAsync(project);
            // Process each...
        }
    }
    

    Saving Projects

    // Save to same location
    string savedPath = await client.SaveProject(
        beamProject: "MyProject",
        saveDestination: @"C:\Projects\MyProject.ebf",
        overwriteExistingFile: true
    );
    
    // Save to new location (copy)
    string savedPath = await client.SaveProject(
        beamProject: "MyProject",
        saveDestination: @"C:\Backups\MyProject_backup.ebf",
        overwriteExistingFile: false
    );
    

    Method Signature

    public async Task<string> SaveProject(
        string beamProject,
        string saveDestination,
        bool overwriteExistingFile)
    

    Parameters

    Parameter Type Description
    beamProject string Project identifier to save
    saveDestination string Full path including filename and .ebf extension
    overwriteExistingFile bool If false and file exists, adds timestamp to filename

    Returns

    The actual path where the file was saved. May differ from saveDestination if overwriteExistingFile is false and the file already exists.

    Example: Save With Backup

    async Task SaveWithBackup(ErikssonBeamClient client, string project, string path)
    {
        // Create backup first
        var backupPath = Path.Combine(
            Path.GetDirectoryName(path),
            $"{Path.GetFileNameWithoutExtension(path)}_backup_{DateTime.Now:yyyyMMdd_HHmmss}.ebf"
        );
    
        await client.SaveProject(project, backupPath, overwriteExistingFile: false);
        Console.WriteLine($"Backup saved to: {backupPath}");
    
        // Save to main location
        var savedPath = await client.SaveProject(project, path, overwriteExistingFile: true);
        Console.WriteLine($"Project saved to: {savedPath}");
    }
    

    Creating Projects

    Create new blank project files:

    await client.CreateProjects(
        projectPaths: new[] {
            @"C:\Projects\NewProject1.ebf",
            @"C:\Projects\NewProject2.ebf"
        },
        failIfFileExists: true
    );
    

    Method Signature

    public async Task CreateProjects(
        string[] projectPaths,
        bool failIfFileExists = true)
    

    Parameters

    Parameter Type Default Description
    projectPaths string[] - Full paths for new project files
    failIfFileExists bool true If true, throws if any file exists. If false, skips existing files.

    Notes

    • Files are created but not opened
    • Use ErikssonBeamFileManager.OpenFiles() to open created files
    • All paths must include the .ebf extension

    Example: Create and Process

    async Task CreateAndProcessProjects(ErikssonBeamClient client, string[] newPaths)
    {
        // Create blank projects
        await client.CreateProjects(newPaths, failIfFileExists: false);
        Console.WriteLine($"Created {newPaths.Length} project files");
    
        // Note: Files are created but not opened
        // To work with them, you need to relaunch or use FileManager
    }
    

    Error Handling

    try
    {
        // Save project
        var path = await client.SaveProject("project", @"C:\Output\project.ebf", true);
    }
    catch (ServerErrorException ex)
    {
        switch (ex.Response.ResponseCode)
        {
            case ResponseCode.InvalidRequest:
                Console.WriteLine($"Invalid request: {ex.Response.ErrorMessage}");
                break;
            case ResponseCode.InternalServerError:
                Console.WriteLine($"Server error: {ex.Response.ErrorMessage}");
                break;
            default:
                Console.WriteLine($"Error: {ex.Response.ErrorMessage}");
                break;
        }
    }
    catch (ObjectDisposedException)
    {
        Console.WriteLine("Client has been disposed");
    }
    

    Complete Example: Batch Processing

    using System;
    using System.IO;
    using System.Threading.Tasks;
    using ErikssonBeam.API.BeamClient;
    
    class BatchProcessor
    {
        static async Task ProcessAndSaveAll(ErikssonBeamClient client, string outputDirectory)
        {
            // Ensure output directory exists
            Directory.CreateDirectory(outputDirectory);
    
            // Get all open projects
            var projects = await client.GetOpenBeamProjects();
            Console.WriteLine($"Found {projects.Length} open projects");
    
            foreach (var project in projects)
            {
                Console.WriteLine($"\nProcessing: {project}");
    
                try
                {
                    // Pull and modify
                    var design = await client.PullBeamDesignerAsync(project);
                    design.DesignCriteria.ProjectInformation.Date = DateTime.Now;
                    design.DesignCriteria.ProjectInformation.DesignerName = "Batch Processor";
    
                    // Push changes
                    await client.PushBeamDesignerAsync(project, design);
    
                    // Save to output directory
                    var outputPath = Path.Combine(outputDirectory, $"{project}.ebf");
                    var savedPath = await client.SaveProject(project, outputPath, overwriteExistingFile: true);
    
                    Console.WriteLine($"  Saved to: {savedPath}");
                }
                catch (ServerErrorException ex)
                {
                    Console.WriteLine($"  Error: {ex.Response.ErrorMessage}");
                }
            }
        }
    
        static async Task Main()
        {
            var args = new ErikssonBeamLauncherArgs
            {
                LicenseKey = Environment.GetEnvironmentVariable("ERIKSSON_LICENSE_KEY"),
                ExecutablePath = @"C:\Program Files\Eriksson Software\Eriksson Beam\ErikssonBeam.exe",
                FilesToOpen = new[]
                {
                    @"C:\Input\project1.ebf",
                    @"C:\Input\project2.ebf",
                    @"C:\Input\project3.ebf"
                },
                CloseErikssonBeamOnClientDisconnect = true
            };
    
            using var launcher = await ErikssonBeamLauncher.LaunchErikssonBeam(args);
    
            await ProcessAndSaveAll(launcher.Client, @"C:\Output\Processed");
    
            Console.WriteLine("\nBatch processing complete!");
        }
    }
    

    See Also

    • ErikssonBeamFileManager - Advanced file management
    • Pulling Data - Retrieve project data
    • Pushing Data - Update project data
    • Edit this page
    In this article
    Back to top Generated by DocFX