[S0012] Get the analysis results in table format

 

To get table format analysis results from a script, there is not only output them to a CSV file, but also retrieving values of specified column and row. Rows refer to step numbers and columns refer to series. By retrieving values within a script, you can perform your own processing and calculations. This script retrieves a table by specifying the result type name, displays the values ​​for each row and column and series names.

Preconditions

  • One or more analysis studies have results.
    This script runs for the active study in the project tree.

Script Function

  • Check whether the study is a transient response type.
    For transient response, time is also acquired.
  • Obtain and display the table values ​​for “Magnetic Flux of Current Conditions” and “Joule Loss.”
  • To acquire table values, get the number of columns and rows and repeat the process.
  • Obtains and displays the column name, i.e., the series name, for each column.
  • For transient response analysis, obtains and displays the time with unit, value, and its unit for each row.
    For other types of analysis, obtains and displays the step number, value, and its unit.
# Copyright (c) 2026 JSOL CORPORATION
#
# This script is released under the MIT License.
# See the full license text at:
# https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/


def isTransient(targetStudy):
    """Checks whether the argument study is transient"""
    isTR = False
    type = targetStudy.GetScriptTypeName() # The return string of GetScriptTypeName is language independent
    if type.lower().find('transient') != -1:
        isTR = True
    return isTR


def getAndDisplayResultTableData(resultTable, tableDataName, isTR):
    """The table results are displayed in column->row order with units assigned"""
    tableData = resultTable.GetData(tableDataName)
    
    print(u"")
    print(tableData.GetName(), u":")
    for i in range(tableData.GetCols()):
        print(tableData.GetColName(i), u":")
        for j in range(tableData.GetRows()):  # A row corresponds to a step
            if isTR:
                print(tableData.GetTime(j), tableData.GetTimeUnit(), ";",
                    tableData.GetValue(j, i), tableData.GetValueUnit()) #  For transient results, time is also displayed
            else:
                print(tableData.GetStep(j), u";", tableData.GetValue(j, i), tableData.GetValueUnit())


app = designer.GetApplication()
targetStudy = app.GetCurrentStudy()
isTR = isTransient(targetStudy)
table = targetStudy.GetResultTable()
getAndDisplayResultTableData(table, u"CoilFlux", isTR)
getAndDisplayResultTableData(table, u"JouleLoss", isTR)

Download Python source code

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.

Search Filter

  • All Categories

An engineer's diary
JMAG-Express Online