Frame#
|   | In this example we will demonstrate how to: 
 | 
from dlubal.api import rfem
def define_structure() -> list:
    """Define and return a list of structural objects."""
    inf = float('inf')
    return [
        # Define material
        rfem.structure_core.Material(no=1, name='S235'),
        # Define section
        rfem.structure_core.Section(no=1, name='HE 200 A', material=1),
        # Define nodes
        rfem.structure_core.Node(no=1),
        rfem.structure_core.Node(no=2, coordinate_3=-3.0),
        rfem.structure_core.Node(no=3, coordinate_1=4.0, coordinate_3=-3.0),
        rfem.structure_core.Node(no=4, coordinate_1=4.0),
        # Define line
        rfem.structure_core.Line(no=1, definition_nodes=[1, 2]),
        rfem.structure_core.Line(no=2, definition_nodes=[2, 3]),
        rfem.structure_core.Line(no=3, definition_nodes=[3, 4]),
        # Define member
        rfem.structure_core.Member(no=1, line=1, section_start=1),
        rfem.structure_core.Member(no=2, line=2, section_start=1),
        rfem.structure_core.Member(no=3, line=3, section_start=1),
        # Define nodal support at Node 1 (fully fixed)
        rfem.types_for_nodes.NodalSupport(
            no=1,
            nodes=[1,4],
            spring_x=inf, spring_y=inf, spring_z=inf,
            rotational_restraint_x=inf,
            rotational_restraint_y=inf,
            rotational_restraint_z=inf
        ),
    ]
def define_loads() -> list:
    """Define and return a list of loading objects."""
    return [
        # Static analysis settings
        rfem.loading.StaticAnalysisSettings(
            no=1,
            analysis_type=rfem.loading.StaticAnalysisSettings.ANALYSIS_TYPE_GEOMETRICALLY_LINEAR,
        ),
        # Define load cases
        rfem.loading.LoadCase(
            no=1,
            name='Self-weight',
            self_weight_active=True,
            static_analysis_settings=1,
        ),
        rfem.loading.LoadCase(
            no=2,
            name='Snow',
            action_category=rfem.loading.LoadCase.ACTION_CATEGORY_SNOW_ICE_LOADS_H_LESS_OR_EQUAL_TO_1000_M_QS,
            static_analysis_settings=1,
        ),
        rfem.loading.LoadCase(
            no=3,
            name='Wind +x',
            action_category=rfem.loading.LoadCase.ACTION_CATEGORY_WIND_QW,
            static_analysis_settings=1,
        ),
        rfem.loading.LoadCase(
            no=4,
            name='Wind +x, with wind suction',
            action_category=rfem.loading.LoadCase.ACTION_CATEGORY_WIND_QW,
            static_analysis_settings=1,
        ),
        rfem.loading.LoadCase(
            no=5,
            name='Wind -x',
            action_category=rfem.loading.LoadCase.ACTION_CATEGORY_WIND_QW,
            static_analysis_settings=1,
        ),
        rfem.loading.LoadCase(
            no=6,
            name='Wind -x, with wind suction',
            action_category=rfem.loading.LoadCase.ACTION_CATEGORY_WIND_QW,
            static_analysis_settings=1,
        ),
        # Define loads
        rfem.loads.MemberLoad(
            no=1,
            load_case=1,
            members=[2],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=1000
        ),
        rfem.loads.MemberLoad(
            no=2,
            load_case=2,
            members=[2],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=3000
        ),
        rfem.loads.MemberLoad(
            no=3,
            load_case=3,
            members=[1],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=2000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=4,
            load_case=3,
            members=[3],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=1000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=5,
            load_case=4,
            members=[1],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=2000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=6,
            load_case=4,
            members=[3],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=1000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=7,
            load_case=4,
            members=[2],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=-500
        ),
        rfem.loads.MemberLoad(
            no=8,
            load_case=5,
            members=[1],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=-2000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=9,
            load_case=5,
            members=[3],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=-1000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=10,
            load_case=6,
            members=[1],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=-2000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=11,
            load_case=6,
            members=[3],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=-1000,
            load_direction=rfem.loads.MemberLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
        ),
        rfem.loads.MemberLoad(
            no=12,
            load_case=6,
            members=[2],
            load_type=rfem.loads.MemberLoad.LOAD_TYPE_FORCE,
            magnitude=-500
        ),
        rfem.loading.CombinationWizard(
            no=1,
            static_analysis_settings=1,
        ),
        rfem.loading.DesignSituation(
            no=1,
            design_situation_type=rfem.loading.DesignSituation.DESIGN_SITUATION_TYPE_STR_PERMANENT_AND_TRANSIENT_6_10,
            combination_wizard=1,
        ),
    ]
with rfem.Application() as rfem_app:
    # Step 1: Create a new model and clear existing objects
    rfem_app.create_model(name='frame')
    rfem_app.delete_all_objects()
    # Step 2: Define and create the structure and load objects
    base_data = rfem_app.get_base_data()
    base_data.combinations_settings.combination_wizard_active = True
    base_data.combinations_settings.result_combinations_active = True
    rfem_app.set_base_data(base_data=base_data)
    # Step 3: Define and create the structure and load objects
    objects = define_structure() + define_loads()
    rfem_app.create_object_list(objects)
    # Step 4: Generate Load Combinations
    print("\nLoad Combinations:")
    rfem_app.generate_combinations()
    all_load_combi = rfem_app.get_object_list([rfem.loading.LoadCombination()])
    # Step 5: Create Result Combination as an envelope from all Load Combinations
    result_combi_rows = []
    for i, load_combi in enumerate(all_load_combi):
        # Check if this is the last item in the list
        print(f"CO{load_combi.no} - {load_combi.combination_rule_str}")
        if i < len(all_load_combi) - 1:
            operator = rfem.loading.ResultCombination.ItemsRow.OPERATOR_OR
        else:
            operator = rfem.loading.ResultCombination.ItemsRow.OPERATOR_NONE
        result_combi_rows.append(
            rfem.loading.ResultCombination.ItemsRow(
                case_object_item=rfem.ObjectId(
                    no=load_combi.no,
                    object_type=rfem.OBJECT_TYPE_LOAD_COMBINATION,
                ),
                case_object_factor=1,
                operator=operator,
            )
        )
    print("\nResult Combination:")
    rfem_app.create_object(
        rfem.loading.ResultCombination(
            no=1,
            user_defined_name_enabled=True,
            name='All ULS',
            design_situation=1,
            items=rfem.loading.ResultCombination.ItemsTable(
                rows = result_combi_rows,
            )
        )
    )
    result_combi = rfem_app.get_object(rfem.loading.ResultCombination(no=1))
    print(f"{result_combi.name} - {result_combi.combination_rule_str}")
    # Step 6: Calculate specific
    rfem_app.calculate_specific(
        loadings=[
            rfem.ObjectId(
                no=1,
                object_type=rfem.OBJECT_TYPE_RESULT_COMBINATION
            )
        ],
        skip_warnings=False,
    )
    # Step 7: Read results using the pre-processed filtering
    results_df = rfem_app.get_results(
        results_type=rfem.results.STATIC_ANALYSIS_MEMBERS_INTERNAL_FORCES,
        filters=[
            rfem.results.ResultsFilter(column_id='member_no',filter_expression='2'),
            rfem.results.ResultsFilter(column_id='loading',filter_expression='RC1'),
        ],
    ).data
    print("\nAll Results:")
    print(results_df)
    # Step 8: Find maximum m_y envelope on specific member
    my_max_df = results_df[results_df['tag'] == 'm_y_max']
    print("\nMaximum My:")
    print(my_max_df)
using Rfem = Dlubal.Api.Rfem;
using Dlubal.Api.Common;
using Google.Protobuf;
using Dlubal.Api.Rfem;
// Returns a list of structural objects to be created
static List<IMessage> DefineStructure()
{
    return new List<IMessage>
    {
        new Rfem.StructureCore.Material {
            No = 1,
            Name = "S235"
        },
        new Rfem.StructureCore.Section {
            No = 1,
            Name = "HE 200 A",
            Material = 1
        },
        new Rfem.StructureCore.Node {
            No=1
        },
        new Rfem.StructureCore.Node {
            No = 2,
            Coordinate3 = -3
        },
        new Rfem.StructureCore.Node {
            No = 3,
            Coordinate1 = 4,
            Coordinate3 = -3
        },
        new Rfem.StructureCore.Node {
            No = 4,
            Coordinate1 = 4
        },
        new Rfem.StructureCore.Line {
            No = 1,
            DefinitionNodes = { 1, 2 }
        },
        new Rfem.StructureCore.Line {
            No = 2,
            DefinitionNodes = { 2, 3 }
        },
        new Rfem.StructureCore.Line {
            No = 3,
            DefinitionNodes = { 3, 4 }
        },
        new Rfem.StructureCore.Member {
            No = 1,
            Line = 1,
            SectionStart = 1
        },
        new Rfem.StructureCore.Member {
            No = 2,
            Line = 2,
            SectionStart = 1
        },
        new Rfem.StructureCore.Member {
            No = 3,
            Line = 3,
            SectionStart = 1
        },
        new Rfem.TypesForNodes.NodalSupport {
            No = 1,
            Nodes = { 1, 4 },
            SpringX = double.PositiveInfinity,
            SpringY = double.PositiveInfinity,
            SpringZ = double.PositiveInfinity,
            RotationalRestraintX = double.PositiveInfinity,
            RotationalRestraintY = double.PositiveInfinity,
            RotationalRestraintZ = double.PositiveInfinity
        }
    };
}
// Returns a list of loading objects to be created
static List<IMessage> DefineLoading()
{
    return new List<IMessage>
    {
        new Rfem.Loading.StaticAnalysisSettings{
            No = 1,
            AnalysisType = Rfem.Loading.StaticAnalysisSettings.Types.AnalysisType.GeometricallyLinear
        },
        new Rfem.Loading.LoadCase {
            No = 1,
            Name = "Self-weight",
            SelfWeightActive = true,
            StaticAnalysisSettings = 1
        },
        new Rfem.Loading.LoadCase {
            No = 2,
            Name = "Snow",
            ActionCategory = Rfem.Loading.LoadCase.Types.ActionCategory.SnowIceLoadsHLessOrEqualTo1000MQs,
            StaticAnalysisSettings = 1,
        },
        new Rfem.Loading.LoadCase {
            No = 3,
            Name = "Wind +x",
            ActionCategory = Rfem.Loading.LoadCase.Types.ActionCategory.WindQw,
            StaticAnalysisSettings = 1
        },
        new Rfem.Loading.LoadCase {
            No = 4,
            Name = "Wind +x, with wind suction",
            ActionCategory = Rfem.Loading.LoadCase.Types.ActionCategory.WindQw,
            StaticAnalysisSettings = 1
        },
        new Rfem.Loading.LoadCase {
            No = 5,
            Name = "Wind -x",
            ActionCategory = Rfem.Loading.LoadCase.Types.ActionCategory.WindQw,
            StaticAnalysisSettings = 1
        },
        new Rfem.Loading.LoadCase {
            No = 6,
            Name = "Wind -x, with wind suction",
            ActionCategory = Rfem.Loading.LoadCase.Types.ActionCategory.WindQw,
            StaticAnalysisSettings = 1
        },
        new Rfem.Loads.MemberLoad {
            No = 1,
            LoadCase = 1,
            Members = { 2 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = 1000
        },
        new Rfem.Loads.MemberLoad {
            No = 2,
            LoadCase = 2,
            Members = { 2 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = 3000
        },
        new Rfem.Loads.MemberLoad {
            No = 3,
            LoadCase = 3,
            Members = { 1 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = 2000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 4,
            LoadCase = 3,
            Members = { 3 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = 1000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 5,
            LoadCase = 4,
            Members = { 1 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = 2000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 6,
            LoadCase = 4,
            Members = { 3 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = 1000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 7,
            LoadCase = 4,
            Members = { 2 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = -500
        },
        new Rfem.Loads.MemberLoad {
            No = 8,
            LoadCase = 5,
            Members = { 1 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = -2000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 9,
            LoadCase = 5,
            Members = { 3 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = -1000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 10,
            LoadCase = 6,
            Members = { 1 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = -2000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 11,
            LoadCase = 6,
            Members = { 3 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = -1000,
            LoadDirection = Rfem.Loads.MemberLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength
        },
        new Rfem.Loads.MemberLoad {
            No = 12,
            LoadCase = 6,
            Members = { 2 },
            LoadType = Rfem.Loads.MemberLoad.Types.LoadType.Force,
            Magnitude = -500,
        },
        new Rfem.Loading.CombinationWizard {
            No = 1,
            StaticAnalysisSettings = 1
        },
        new Rfem.Loading.DesignSituation {
            No = 1,
            DesignSituationType = Rfem.Loading.DesignSituation.Types.DesignSituationType.StrPermanentAndTransient610,
            CombinationWizard = 1
        }
    };
}
ApplicationRfem? RfemApp = null;
try
{
    RfemApp = new ApplicationRfem();
    // Step 1: Create a new model and delete all predefined objects
    await RfemApp.close_all_models(false);
    await RfemApp.create_model("Frame");
    await RfemApp.delete_all_objects();
    // Step 2: Configure the combination settings
    Rfem.BaseData baseData = await RfemApp.get_base_data();
    baseData.CombinationsSettings.CombinationWizardActive = true;
    baseData.CombinationsSettings.ResultCombinationsActive = true;
    await RfemApp.set_base_data(baseData);
    // Step 3: Create the structure and load objects
    await RfemApp.create_object_list(DefineStructure());
    await RfemApp.create_object_list(DefineLoading());
    // Step 4: Generate Load Combinations
    await RfemApp.generate_combinations();
    // Step 5: Create Result Combination as an envelope from all Load Combinations
    var loadCombinationList = await RfemApp.get_object_list(
        new List<IMessage> {
            new Rfem.Loading.LoadCombination()
        }
    );
    var resultCombiRows = new List<Rfem.Loading.ResultCombination.Types.ItemsRow>();
    int index = 0;
    int lastIndex = loadCombinationList.Count - 1;
    foreach (var obj in loadCombinationList)
    {
        if (obj is Rfem.Loading.LoadCombination loadCombi)
        {
            Console.WriteLine($"{Rfem.Loading.LoadCombination.Descriptor.Name} | CO{loadCombi.No} | {loadCombi.CombinationRuleStr}");
            var operatorType = (index < lastIndex)
                ? Rfem.Loading.ResultCombination.Types.ItemsRow.Types.Operator.Or
                : Rfem.Loading.ResultCombination.Types.ItemsRow.Types.Operator.None;
            resultCombiRows.Add(new Rfem.Loading.ResultCombination.Types.ItemsRow
            {
                CaseObjectItem = new Rfem.ObjectId
                {
                    ObjectType = Rfem.ObjectType.LoadCombination,
                    No = loadCombi.No
                },
                CaseObjectFactor = 1,
                Operator = operatorType,
            });
            index++;
        }
    }
    var resultCombiTable = new Rfem.Loading.ResultCombination.Types.ItemsTable();
    resultCombiTable.Rows.Add(resultCombiRows);
    await RfemApp.create_object(
        new Rfem.Loading.ResultCombination{
            No = 1,
            UserDefinedNameEnabled = true,
            Name = "ALL ULS",
            DesignSituation = 1,
            Items = resultCombiTable,
        }
    );
    var resultCombi = await RfemApp.get_object<Rfem.Loading.ResultCombination>(
        new Rfem.Loading.ResultCombination{No=1}
    );
    Console.WriteLine($"{Rfem.Loading.ResultCombination.Descriptor.Name} | {resultCombi.Name} | {resultCombi.CombinationRuleStr}");
    // Step 6: Calculate specific
    await RfemApp.calculate_specific(
        loadings: new List<Rfem.ObjectId>
        {
            new Rfem.ObjectId{
                ObjectType = Rfem.ObjectType.ResultCombination,
                No = 1
            }
        },
        skipWarnings: false
    );
    // Step 7: Read results using optional filtering
    var results = await RfemApp.get_results(
        resultsType: Rfem.Results.ResultsType.StaticAnalysisMembersInternalForces,
        filters: new List<Rfem.Results.ResultsFilter> {
            new Rfem.Results.ResultsFilter
            {
                ColumnId = "member_no",
                FilterExpression = "2"
            }
        }
    );
    Console.WriteLine($"Results | Static Analysis | Member No=2:\n{results.Data}");
}
catch (Exception ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}
finally
{
    if (RfemApp != null) await RfemApp.close_connection();
}