🤖 New in SPACE GASS 14.51 — the MCP server lets your AI agent build, analyse and design your models. Get started →
SpaceGass API
Recipes

Open your own .sg file

The Quick Start uses Job.OpenSample to load a built-in sample so you don't need a project file. Once you have your own .sg file, switch to Job.Open — same shape, but you supply the path.

Check the file status first

Before opening, call File.Status to find out whether the file is in a safe state. The response includes CanOpenSafely (a simple boolean), a human-readable Description, and a RecommendedAction string you can show to the user if something is wrong.

using SpaceGassApi; using SpaceGassApi.Models; var client = SpaceGassApiClient.CreateClient("http://localhost:34560"); var status = await client.File.Status.GetAsync( config => config.QueryParameters.FilePath = @"C:\Projects\MyStructure.sg"); Console.WriteLine($"Status: {status!.Status}"); Console.WriteLine($"Description: {status.Description}"); Console.WriteLine($"Can open safely: {status.CanOpenSafely}"); if (status.CanOpenSafely != true) { Console.WriteLine($"Recommended action: {status.RecommendedAction}"); }

Open the file

Job.Open returns 409 Conflict if a job is already open — close it first with Job.Close. If the file has unsaved temporary files from a previous crashed session, set ForceOption on the request body to either OpenPreviousSaved (discard the unsaved changes) or OpenUnsavedMostRecent (recover them).

using SpaceGassApi; using SpaceGassApi.Models; var client = SpaceGassApiClient.CreateClient("http://localhost:34560"); try { await client.Job.Open.PostAsync( new OpenJobRequest { FilePath = @"C:\Projects\MyStructure.sg" }); // ...do work on the open job... } finally { await client.Job.Close.PostAsync(); }

See also

Last modified on