Changing Soil Material in Calculation Stages using python

I have a list of Material Datasets saved in a List in Python (e.g. for unfactored Undrained materials the List is Unfac_Undr_MatSets).

in the Staged Construction, I want to change the Material in each borehole volume from respective material in Drained Material set to respective material in Undrained Data set.

for i in range(len(Unfac_Undr_MatSets)):
    g_i.BoreholeVolumes[i].Material.set(Loadphase, Unfac_Undr_MatSets[i])

The Output is giving an error as "Requested attribute 'BoreholeVolumes' is not present". Am I getting the object or syntax wrong? Should I have used Soilvolumes[i]? Does anyone have any example regarding this.

Thanks in advance.

Regards

Sangeet

  • Dear Sangeet,

    The best way to find if you are trying to access the property the correct way is to first try it manually (or via GUI) in PLAXIS.

    If you try to manually change the material of a BoreholeVolume you get this command:

    set Soil_1_1.Material Phase_5 Clay

    That indicates that it is the Soil object that has the property Material. If you check on the Model explorer or via the echo command you can see that the Soil object is under the BoreholeVolume, so I would expect that adding the .Soil will do the trick:

    for i in range(len(Unfac_Undr_MatSets)):
        g_i.BoreholeVolumes[i].Soil.Material.set(Loadphase, Unfac_Undr_MatSets[i])

  • Hi Stefanos,

    Thank you so much for your prompt response. The approach with BoreholeVolumes[i] doesn't seem to work even if I applied .Soil after it as suggested. However I solved it using the Soil object itself. I just want to share it in case anyone needs to use this method.

    I should also mention that your approach towards solving a problem is brilliant!!! it actually helped me to think out  of the box. The working code below in case anyone needs it:

    for soil in g_i.Soils[:]:
        for i in range(len(Unfac_Undr_MatSets)):
            if str(soil.Material[g_i.Phases[0]].Name.value) == Unfac_Dr_MatSets[i].MaterialName:
                soil.setmaterial(Loadphase, Unfac_Undr_MatSets[i])

    Many regards and thanks again.

  • Hello again,

    First of all great that you managed to find a solution. I spotted why it did not work.

    You are looping over the g_i.BoreholeVolumes, which actually is g_i.SoilVolumes as the correct group name in PLAXIS model explorer.
    Then, you loop over using the range() which is fine, and that means that you are accessing the g_i.SoilVolumes list.

    Therefore this command should work just fine (works for me):
    g_i.SoilVolumes[i].Soil.Material.set(Loadphase, Unfac_Undr_MatSets[I])

    Naturally, the approach you took to go over the Soil objects is also correct. It's up to you where you want to access the Material property from.

    Note that the more Pythonic way of assigning a material is:

    g_i.SoilVolumes[i].Soil.Material[Loadphase] = Unfac_Undr_MatSets[I])