# 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")