The distribution of calculation results can be output to a file in a table format by specifying nodes or elements.
While the GUI displays the results on screen, the scripting interface supports outputting them into a file.
This script outputs the magnetic flux density results for the elements constituting the selected part as a CSV file.
Preconditions
- One or more study has been calculated.
This script runs on the active magnetic field analysis study in the project tree. - The name of the parts to be output is known.
- JMAG-Designer is not running in no-window mode.
Selecting the output targets for the result table cannot be performed in non-window mode.
Script Function
- Specify the details of the results to be output
Result type: Magnetic flux density
Component: All components
Step interval: 1 (include all steps)
Include maximum/minimum values and element positions in the output. - Select the "Rotor" part as the output target.
- Export the CSV file to the same directory as the currently opened project file.
The file format is determined by the extension specified in the output file name.
Output using the JMAG-Designer format.
* Output is possible in either JMAG-Designer format or the legacy JMAG-Studio format.
There are differences in the data matrix and the available output information between the two formats.
(Note: The JMAG-Studio format does not support selecting "All components" or outputting positional information.)
# 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/
import os
app = designer.GetApplication()
def createTableDefinition(study, tableDefParam):
"""Create the calculation result quantity and output content to be output and return the settings."""
definition = study.CreateTableDefinition()
definition.SetResultType(tableDefParam[u"resultType"])
# The Argument of SetCoordinate
# Name or index
# The name of the preset coordinate system is fixed according to the language setting.
# The index is specified in a 0-based from the coordinate system definition list order under Project - Model - Coordinate Systems
definition.SetCoordinate(tableDefParam[u"coordinate"])
definition.SetComponent(tableDefParam[u"component"])
definition.SetStepsByInterval(tableDefParam[u"stepInterval"])
definition.SetIsShownMinMaxInfo(tableDefParam[u"showMinMaxInfo"])
definition.SetIsShownPositionInfo(tableDefParam[u"showPositionInfo"])
return definition
def getFolderPathOfOpenedProjectFile():
"""Get folder path of opened jproj file"""
openedJprojFilePath = app.GetProjectPath()
folderPath = os.path.dirname(openedJprojFilePath)
return folderPath
model = app.GetCurrentModel()
study = app.GetCurrentStudy()
tableDefParam = {
u"resultType" : u"MagneticFluxDensity",
u"coordinate" : 0,
u"component" : u"All",
u"stepInterval" : 1,
u"showMinMaxInfo" : True,
u"showPositionInfo" : True,
}
tableDefinition = createTableDefinition(study, tableDefParam)
# Select target parts.
sel = model.CreateSelection()
sel.SelectPart(u"IPM/rotor-1")
folderPath = getFolderPathOfOpenedProjectFile()
fileName = u"MagneticFluxDensity.csv"
outputFullPath = os.path.join(folderPath, fileName)
# The table output format can be selected from the following options.
# designer: Outputs tables in JMAG-Designer format.
# studio: Outputs tables in JMAG-Studio format.
study.ExportTable(tableDefinition, outputFullPath, "designer")


