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


  • 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:


    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 *
    # 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,
                # check if position lies outside the mesh
                if result_string == "not found":
                    raise Exception("Used getsingleresult for point outside mesh.")
            # add the row
        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])
        # 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:
        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 = []
        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)

    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.

Reply Children
No Data