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

Save and close cleanly

Job.Save writes the active job to a .sg file. The filePath works like Save As — pass any path you want; the file is created (or overwritten) at that location. Wrap the work in try / finally so Job.Close runs even if a step in the middle throws, otherwise the service is left holding an active job and the next Open will return 409.

The snippet below opens the Portal Frame.SG sample, saves it as a new file on the desktop, and closes the job — useful as a template for any "open something, save it as something else" workflow.

using SpaceGassApi; using SpaceGassApi.Models; var savePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "PortalFrameCopy.sg"); var client = SpaceGassApiClient.CreateClient("http://localhost:34560"); try { await client.Job.OpenSample.PostAsync( new OpenSampleRequest { FileName = "Portal Frame.SG" }); // ...modify the model however you like... await client.Job.Save.PostAsync( new SaveJobRequest { FilePath = savePath }); Console.WriteLine($"Saved to {savePath}"); } finally { await client.Job.Close.PostAsync(); }

If you want to save to the path the job was originally opened from, omit filePath — the API saves over the original. (Sample projects opened with Job.OpenSample are unsaved and have no original path, so you must supply one.)

See also

Last modified on