Modifying specific weight of a library material

Hello everyone,

I’m working with the RFEM6 Python API II and need to modify only the specific weight (γ) and mass density (ρ) of an existing concrete material. I understand that these properties live in the material’s temperature‐dependent row table, but I haven’t found a concise, reliable approach to update just those two fields without re‑defining the entire material.

Here’s what I’ve tried so far:

  1. Create a brand‑new Material object matching the enums of the original (model, type, definition), then force is_temperature_dependent = True, add or reuse the first temperature row, and override its specific_weight and mass_density before pushing via create_object_list().
  2. Deep‑copy the original Material, change its no and name, enable temperature dependence, update the first temperature row, and push the copy back.

In both cases, logging before and after showed that the new row values never “stick” once the model is reloaded. I also verified I’m targeting row 1 for both weight and density, but still end up with the original values.

Whats the easiest way to accomplish this?

Thanks!
Samuel

Hi Samuel,

thanks for bringing this up!
We are aware of this limitation and are currently working on a solution. Unfortunately, there is no straightforward workaround at the moment. However, we plan to make it possible to update an existing material—including specific weight and mass density—or to create a deep copy with modified properties in a future update.

I’ll keep you posted as soon as this becomes available.

Best regards,
Tomas

2 Likes

Ok thanks very much for letting me know!
I work off a template model so I think in the mean time it will work to just use the UI to copy the most common concrete's I tend to use and manually change the values I need, note the corresponding material numbers in python and just assign materials rather than trying to modify :)

Hi Samuel,

Just wanted to let you know that the issue has already been solved in version 6.11.0011/2.11.11, and no workaround is necessary anymore. You can directly update the material properties, such as mass density and specific weight, using the following approach:

mat_2: rfem.structure_core.Material = rfem_app.get_object(
    rfem.structure_core.Material(no=2)
)
print(mat_2)

mat_2.no = 4
mat_2.user_defined = True
mat_prop = mat_2.temperature.rows[0]
mat_prop.mass_density = 2400
mat_prop.specific_weight = 24000

rfem_app.create_object(mat_2)

mat_4 = rfem_app.get_object(rfem.structure_core.Material(no=4))
print(mat_4)

Thanks again for your patience, and hope this solution works for you!

Best,

1 Like

Thanks Tomas,

That worked well!

I really appreciate the development team constantly improving the features, and you and your colleagues being communicative with these developments :slight_smile:

Samuel

2 Likes

Hi Tomas,

Quick follow-up - my original code worked fine previously (not sure what version it last worked on, testing again now in 6.12.8). It was:

if base_type == "pilecap_base":
    buoyant_mat_no = 3
    all_objects.append(rfem.structure_core.Material(
        no=buoyant_mat_no,
        name=foundation_material_name,
        user_defined=True
    ))

Then after bulk create:

mat_3 = rfem_app.get_object(rfem.structure_core.Material(no=3))
mat_prop = mat_3.temperature.rows[0]
mat_prop.mass_density = original_mass_density - 9.81
mat_prop.specific_weight = original_specific_weight - 9810
rfem_app.update_object(mat_3)

In 6.12.8 this started failing with "Failed to update Material No. 3. Material No. 3 does not have the property user_material_guid."

I assumed GUID is now required, so I tried adding it when creating Material 3:

material_guid = str(uuid.uuid4())
mat_3 = rfem.structure_core.Material(
    no=buoyant_mat_no,
    name=foundation_material_name
)
mat_3.user_defined = True
mat_3.user_material_guid = material_guid
all_objects.append(mat_3)

But then got "Failed to create Material No. 3. Material No. 3 does not have the property user_material_guid."

Is the guid meant to be created manually by me like above, or what code should it be?

In Material — Dlubal API documentation it says its User Material Guide so not sure if its meant to be a global unique identifier or something else? It just says string so I’m assuming guide is a misspelling and it is a guid? But I would expect the api to generate it rather than me making it, and given I’m getting an error I think I am intepreting it wrong.

Let me know what I should be coding.

Thanks,
Samuel

Hey,

I saw that in the latest update 6.12.0010 there were the following developments
Modify Material Design Values and Allow Getting/Updating Material Properties Independent of Temperature (both for 81.12 API – gRPC Server)

So I updated and tried again but I still get the error I described in my previous comment

Is there any guidance about how to update my code for the new version?

I’ve also noticed after looking more into the api docs to help figure this out that under User-defined Material — Dlubal API documentation it doesn’t have anything with guid so I couldn’t get any additional info from this.

Hi Samuel,

Sorry for the delayed response. I would try to modify your code in the following manner:

from dlubal.api import rfem, common

with rfem.Application() as rfem_app:

    mat_3 = rfem_app.get_object(rfem.structure_core.Material(no=2))
    print(mat_3.material_values.rows[0])

    mat_prop = rfem.structure_core.Material.MaterialValuesRow.MaterialValuesTreeTable()
    common.set_tree_value(mat_prop, ['basic_properties', 'rho'], 2400.0)        # mass density
    common.set_tree_value(mat_prop, ['basic_properties', 'gamma'], 24000.0)     # specific weight                               
    mat_3.material_values.rows[0].material_values_tree.CopyFrom(mat_prop)  

    rfem_app.update_object(
        rfem.structure_core.Material(
            no=2,
            user_defined=True,
            material_values=mat_3.material_values
        )
    )

Hopefully, this will help for now. As for TreeTables in general, we're still working on improvements and simplifications. For example, we're exploring ways to modify the original TreeTable directly instead of creating a new one with just the modifications. Stay tuned, and sorry that the API is still a bit live.

Regards,

1 Like