Results Access#
|
In this example we will demonstrate how to:
|
from dlubal.api import rfem, common
with rfem.Application() as rfem_app:
# --- get_results ---
# Retrieves complete, unprocessed results from the RFEM database.
# These results are returned wrapped in a DataFrame (.data).
results:common.Table = rfem_app.get_results(
results_type=rfem.results.ResultsType.STATIC_ANALYSIS_NODES_GLOBAL_DEFORMATIONS,
filters=[
rfem.results.ResultsFilter(column_id='loading', filter_expression='LC6')
]
)
print(f"\nResults:\n{results.data}")
# --- get_result_table ---
# Retrieves a pre-processed result table wrapped in a DataFrame (.data),
# containing only the most relevant values as displayed in the RFEM desktop application.
result_table:common.Table = rfem_app.get_result_table(
table = rfem.results.ResultTable.STATIC_ANALYSIS_NODES_GLOBAL_DEFORMATIONS_TABLE,
loading= rfem.ObjectId(
no=6,
object_type=rfem.OBJECT_TYPE_LOAD_CASE
)
)
print(f"\nResult Table:\n{result_table.data}")
# # --- has_results ---
# # Checks if results exist for a specified loading condition.
# # This is useful to confirm results availability before retrieving them,
# # preventing errors or unnecessary data requests.
# has_results = rfem_app.has_results(
# loading = rfem.ObjectId
# (
# no = 1,
# object_type = rfem.OBJECT_TYPE_LOAD_COMBINATION,
# )
# )
# print(f"\nResults Available: {has_results.value}")
using Rfem = Dlubal.Api.Rfem;
using Common = Dlubal.Api.Common;
using Google.Protobuf;
static List<IMessage> DefineStructure()
{
return new List<IMessage>
{
new Rfem.StructureCore.Material { No = 1, Name = "S235" },
new Rfem.StructureCore.CrossSection { No = 1, Name = "HE 300 A", Material = 1 },
new Rfem.StructureCore.Node { No = 1, Coordinate1 = 0 },
new Rfem.StructureCore.Node { No = 2, Coordinate1 = 6 },
new Rfem.StructureCore.Line { No = 1, Type = Rfem.StructureCore.Line.Types.Type.Polyline, DefinitionNodes = { 1, 2 } },
new Rfem.StructureCore.Member { No = 1, Type = Rfem.StructureCore.Member.Types.Type.Beam, Line = 1, CrossSectionStart = 1 },
new Rfem.TypesForNodes.NodalSupport
{
No = 1,
Nodes = { 1 },
SpringX = double.PositiveInfinity,
SpringY = double.PositiveInfinity,
SpringZ = double.PositiveInfinity,
RotationalRestraintX = double.PositiveInfinity,
RotationalRestraintY = double.PositiveInfinity,
RotationalRestraintZ = double.PositiveInfinity
},
};
}
static List<IMessage> DefineLoading()
{
var objects = new List<IMessage>
{
new Rfem.Loading.StaticAnalysisSettings { No = 1 },
};
for (int i = 1; i <= 6; i++)
{
objects.Add(new Rfem.Loading.LoadCase
{
No = i,
Name = $"LC{i}",
StaticAnalysisSettings = 1,
SelfWeightActive = false,
});
}
objects.Add(new Rfem.Loads.NodalLoad
{
No = 1,
LoadCase = 6,
Nodes = { 2 },
LoadType = Rfem.Loads.NodalLoad.Types.LoadType.Components,
ComponentsForceZ = 10000,
});
return objects;
}
ApplicationRfem? rfemApp = null;
try
{
rfemApp = new ApplicationRfem();
rfemApp.close_all_models(saveChanges: false);
rfemApp.create_model(name: "results_access");
rfemApp.delete_all_objects();
rfemApp.create_object_list(DefineStructure());
rfemApp.create_object_list(DefineLoading());
rfemApp.calculate_all(skipWarnings: true);
// --- get_results ---
Common.Table results = rfemApp.get_results(
resultsType: Rfem.Results.ResultsType.StaticAnalysisNodesGlobalDeformations,
filters: new List<Rfem.Results.ResultsFilter>
{
new Rfem.Results.ResultsFilter { ColumnId = "loading", FilterExpression = "LC6" }
}
);
Console.WriteLine($"\nResults:\n{results.Data}");
// --- get_result_table ---
Common.Table resultTable = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.StaticAnalysisNodesGlobalDeformationsTable,
loading: new Rfem.ObjectId
{
No = 6,
ObjectType = Rfem.ObjectType.LoadCase
}
);
Console.WriteLine($"\nResult Table:\n{resultTable.Data}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
finally
{
if (rfemApp != null) rfemApp.close_connection();
}