Exporting cross-section table results from Plaxis 2D to .txt file

Greetings all,

I am currently running several thousands of dynamic nonlinear deformation analysis with approximately 15 k elements per model. As you may understand, with such numbers it is difficult to evaluate results manually.

I was able to prepare the models automatically following the command line outcomes but when it comes to post-processing, command lines do not show the commands for every step.

For example, to cut a cross-section and extract results manually, following is what I do:

1. Cut the cross-section using Tools>Cross section

2- Select the output type (say horizontal displacement at that phase)

3 - Click on the table icon by right clicking on the cross section

4 - Select all data

5 - Export to .txt

After doing this manually, I am able to utilize python because at this point it is independent of Plaxis.

Is there any way to do above 5 steps automatically by "Run Commands" option? I am a python user and I have tried to follow the python scripting guidelines but found it difficult to understand and put the pieces together to do what I want to do above.

Thank you

Oz

  • With the command runner alone, you will not be able to export the data to a text file. 

    To make cross-sections and automatically export the data, I suggest to use Python as you already mentioned.

    Here is a good starter:

    https://communities.bentley.com/products/geotech-analysis/w/plaxis-soilvision-wiki/45440/automatic-line-cross-section-chart-generation-using-python

    And instead of putting the results in a plot, you can write this to a text file. Based on the above example, you could make it like this:

    import os
    from plxscripting.easy import *
    
    # BOILERPLATE #
    # initialize PLAXIS OUTPUT
    port = "YOUR OUTPUT PORT"
    password = r'YOUR PASSWORD'
    s_o, g_o = new_server('localhost', port, password=password)
    
    def gather_results(phase, resultobjects, start, end, sample_count=16):
        """ retrieves the results for the given line from start to end """
        step = [(e - s) / (sample_count - 1) for e, s in zip(end, start)]
        results = []
        for i in range(sample_count):
            position = (start[0] + i * step[0],
                        start[1] + i * step[1])
            # first two values are the coordinates:
            values = [position[0], position[1]]
            for resultobj in resultobjects:
                result_string = g_o.getsingleresult(phase,
                                                    resultobj,
                                                    position)
                # check if position lies outside the mesh
                if result_string == "not found":
                    raise Exception("Used getsingleresult for point outside mesh.")
    
                values.append(float(result_string))
    
            # add the row
            results.append(values)
        return results
    
    def writeresults(folder, phase, resultobjects, results):
        """ writing the data to a text file
    
        :param folder: path to the folder where the data will be saved
        :param phase: phase object, the name will be used to create the name
        :param resultobjects: list of result objects, to be used for the table header
        :param results: list of results
        :return: .txt filename
        """
        txtfile = os.path.join(folder, 'results_{}.txt'.format(phase.Name.value))
        rows = []
        # first two entries are X and Y for 2D:
        header = ["X", "Y"]
        header.extend([str(i) for i in resultobjects])
        rows.append(header)
        rows.extend(results)
    
        # construct text lines for the results
        delimiter = '\t'
        txtlines = []
        for row in rows:
            txtlines.append(delimiter.join([str(cell) for cell in row]))
    
        # write text file
        with open(txtfile, 'w') as f:
            f.write('\n'.join(txtlines))
    
        return txtfile
    
    
    def getResultsMultiplePhases():
        """ gets results for multiple phases and writes them to a text file """
        sample_count = 16
        start = (4.0, 4.0)
        end = (4.0, -10)
        # assumes that start and end contain floats
    
        resultobjects = []
        resultobjects.append(g_o.ResultTypes.Soil.Ux)
        resultobjects.append(g_o.ResultTypes.Soil.Uy)
        resultobjects.append(g_o.ResultTypes.Soil.MeanEffStress)
    
        phases = [g_o.Phase_3, g_o.Phase_4]
        folder = r'D:\test data'
    
        for phase in phases:
            results = gather_results(phase, resultobjects, start, end, sample_count)
            newfile = writeresults(folder, phase, resultobjects, results)
            print('Created:', newfile)
    
    
    getResultsMultiplePhases()
    

    Alternatively, you want to use the report generator to save the table of a cross-section to a Saved View. But for this, you would need to redo this for every model, but at least you can automate this for every phase in each PLAXIS project file.

  • Hi, 

    Its been years since plaxis started evolving and the cross-section curves feature is a pretty old one. Why not the commands get generated as we operate the plaxis output(as we see in Input) for the creation of cross-section curve plots so that we do not have to all these kind of work arounds?

    Why is the command runner doesn't work in the Output application which seems to be a major aspect missing to those who wish to use the scripting interface for repetitive tasks?

    This is pretty much important feature to almost everyone whenever a parameter has to be looked through the phases in a plot. Moreover, It would be nice to also add commands to extract the tabulated result summary than doing this cumbersome way.. We are already in to 20th version. Please add this future so that we should be able to focus on analyzing the results than spending most of time in extracting the results thereby loosing time in the actual one.

    One more important feature request:

    I also find couple of additional features interesting like showing options for weighted average value in addition to the shown min & Max values.

  • Dear Duggirala,

    Thank you for your feedback! I have already replied to the service request you submitted earlier today and I will also comment here.

    I totally agree that we are missing this functionality. We will continue working on improving our scripting support and we will cover the cross-sections data. 

    Output, in general, handles mostly the visualisation of the model. That explains why the commands are not automatically generated as Input does.
    We have covered, though, all available commands with our Scripting reference: https://communities.bentley.com/products/geotech-analysis/w/plaxis-soilvision-wiki/45447/scripting-reference-and-how-to-use-it

    Naturally, we cannot cover all possible cases in the vastness of projects that users handle, but via a service request we can assist you further if needed.

    In any case, I have passed all comments as feedback to our developers.