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

Read reactions for restrained nodes only

Common after an analysis: you only care about reactions at supports, not internal nodes. Two-step: filter nodes to NodeType=Restrained to get the support node Ids, then pass them as the Nodes filter on the reactions endpoint.

Nodes accepts SG list format — comma-separated Ids and dash ranges ("1,3-7,10"). Build it with string.Join(",", ids) (C#) or ",".join(...) (Python).

The snippet below opens the Portal Frame.SG sample, runs a linear static analysis to populate reactions, queries restrained nodes, then prints their reactions. try / finally closes the job even if a step in the middle throws.

using SpaceGassApi; using SpaceGassApi.Models; var client = SpaceGassApiClient.CreateClient("http://localhost:34560"); try { await client.Job.OpenSample.PostAsync( new OpenSampleRequest { FileName = "Portal Frame.SG" }); // Run analysis so reactions are available. var run = await client.Job.Analysis.Static.RunLinear.PostAsync( new StaticSettingsUpdate()); while (true) { await Task.Delay(500); var s = await client.Job.Analysis.Runs[run!.RunId!.Value].GetAsync(); if (s!.Status is RunStatus.Completed or RunStatus.Failed or RunStatus.Cancelled) break; } // 1. Get the restrained nodes var restrained = await client.Job.Structure.Nodes.GetAsync( config => config.QueryParameters.NodeType = NodeTypeFilter.Restrained); var nodeFilter = string.Join(",", restrained!.Where(n => n.Id != null).Select(n => n.Id!.Value)); // 2. Read reactions filtered to those nodes var result = await client.Job.Query.Analysis.Static.NodeReactions.GetAsync( config => config.QueryParameters.Nodes = nodeFilter); foreach (var r in result!.Results!) { Console.WriteLine( $"Node {r.Node}, Case {r.LoadCase}: " + $"Fx={r.Fx:F2}, Fy={r.Fy:F2}, Fz={r.Fz:F2}"); } } finally { await client.Job.Close.PostAsync(); }

Run this example locally

The same code (against your own .sg file rather than the sample) is in the repo as Example.QueryRestrainedNodes (C#) and query_restrained_nodes (Python). Clone and run:

git clone https://github.com/SpaceGass/space-gass-api.git cd space-gass-api/sdks/csharp/examples/Example.QueryRestrainedNodes dotnet run

Edit the example's PROJECT_FILE_PATH constant first to point at an analysed .sg file.

See also

Last modified on