API2: running the example from the documentation page throws exception

using the Dlubal.API Nuget package versions 2.12.11 or 2.12.10 together with RFEM 6.12.0010, I tried to recreate the C# example on the documentation page here, but I get the following error:

the IMessage creating the cross-section fails.

Below is my code:

using ClassLibrary_helperClasses;
using Dlubal.Api.Rfem.StructureCore;
using Google.Protobuf;
using Rfem = Dlubal.Api.Rfem;

private async void Run()
{
    await base.CreateNewModel("test");

    await base.Application.delete_all_objects();

    //await base.Application.create_object_list(this.Get_messageList_structure());


    foreach (IMessage msg in this.Get_messageList_structure())
    {
        await base.Application.create_object(msg);
    }

    await base.Application.close_connection();
}


public async Task<ModelId> CreateNewModel(string modelName)
{
    ModelId modelId = await this.Application.create_model(name: modelName);

    await SetBaseData(modelName);

    return modelId;
}

        private async Task<bool> SetBaseData(string modelName)
        {
            try
            {
                BaseData base_data = await this.Application.get_base_data();

                base_data.CombinationsSettings = new BaseData.Types.CombinationsSettings()
                {
                    AutomaticallyGenerateCorrespondingLoadCombinations = false,
                    CombinationWizardActive = false,
                    ResultCombinationsActive = true,
                    GenerateLoadCasesFromConstructionStagesJustBeforeCalculationActive = false,
                    ResultCombinationsParenthesesActive = true,
                };

                //base_data.GeneralSettings = new BaseData.Types.GeneralSettings()
                //{
                //    GlobalAxesOrientation = BaseData.Types.GeneralSettings.Types.GlobalAxesOrientation.Zup,
                //    GravitationalAcceleration = 9.81,
                //    ToleranceForDirections = 0.001,
                //    ToleranceForLines = 0.001,
                //    ToleranceForNodes = 0.001,
                //    ToleranceForSurfaces = 0.001
                //};

                //base_data.Standards = new BaseData.Types.Standards()
                //{
                //    SteelDesignStandardGroup = BaseData.Types.Standards.Types.SteelDesignStandardGroup.En1993StandardGroup,
                //    ConcreteDesignStandardGroup = BaseData.Types.Standards.Types.ConcreteDesignStandardGroup.En1992StandardGroup,
                //};

                //base_data.Addons = new BaseData.Types.Addons()
                //{
                //    SteelDesignActive = true,
                //    ConcreteDesignActive = true,
                //};

                //base_data.Main = new BaseData.Types.Main()
                //{
                //    BuildingGridActive = 1,
                //    MembersActive = true,
                //    ModelType = BaseData.Types.Main.Types.ModelType._3D,
                //    SurfacesActive = true,
                //    ModelName = modelName
                //};

                await this.Application.set_base_data(baseData: base_data);

            }
            catch (Exception e)
            {
                var stackTrace = new System.Diagnostics.StackTrace(e, true);
                var message = e.Message + ":\r\n\r\n" + stackTrace + "\r\n\r\n" + "An error occurred";
                Console.WriteLine(message);
                Console.ReadLine();
                return false;
            }


            return true;
        }


private List<IMessage> Get_messageList_structure()
{
    return new List<IMessage>
        {
            new Rfem.StructureCore.Material{
                Name="S235"
            },
            new Rfem.StructureCore.CrossSection{
                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,
                SpringX = double.PositiveInfinity,
                SpringY = double.PositiveInfinity,
                SpringZ = double.PositiveInfinity,
                RotationalRestraintX = double.PositiveInfinity,
                RotationalRestraintY = double.PositiveInfinity,
                RotationalRestraintZ = double.PositiveInfinity,
                Nodes = { 1 }
            },
        };
}

The API recommends the use of API version 2.6.10 with RFEM 6.12.0010. But, using that API version breaks other places in the code, as shown below.

trying it without the .ToString() method, gives the same error:

trying it without giving any inputs to the method (like how it used to work with v.2.6.11) also gives the same error:

commenting out the line for getting the base data, arrives at the same problem mentioned at the top of this post.

The other issue is that even when I have the API version 2.6.10 installed, I still receive the warning message that there is incompatibility and I should install version 2.6.10!

Hi PSA001,

Please keep this post in mind:
:backhand_index_pointing_right: https://community.dlubal.com/t/new-terminology-section-cross-section/2496

Our examples are usually created for the latest software versions. Since there was a major change introduced in version 2.12.11, we recommend that you continue using the RFEM + API versions mentioned in the post above. This should ensure that the examples work correctly and consistently.

:backhand_index_pointing_right: Dlubal API | Getting Started

Regarding the version mismatch error, unfortunately I can’t provide further details at the moment.

Best regards
Stefan Hoffmann

Hi PSA001,

Could you please try deleting your NuGet packages from the following path:
C:\Users\YourUserName\.nuget\packages\dlubal.api\

Once done, try installing the package again by running the following command:
dotnet add package Dlubal.Api --version 2.12.12

Make sure to adjust the version according to the RFEM version you're using (e.g., 2.12.12 for RFEM 6.12.12).

I hope this resolves both issues.

2 Likes