# Copyright (c) 2026 JSOL CORPORATION # # 本スクリプトはMITライセンスのもとで公開しています。 # ライセンス全文は以下を参照してください。 # https://www.jmag-international.com/jp/scriptlibrary/jmag_script_library_mit/ import os app = designer.GetApplication() def createTableDefinition(study, tableDefParam): """出力する計算結果量と出力内容を作成して設定を返す""" definition = study.CreateTableDefinition() definition.SetResultType(tableDefParam[u"resultType"]) # The Argument of SetCoordinate # 名称かインデックス # プリセット座標系の名称は言語設定に従って固定 # インデックスはプロジェクト-モデル-座標系の下にある座標系定義から0ベースで指定 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(): """開かれているjprojファイルのフォルダのパスを取得する""" 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) # 対象となる部品を選択する sel = model.CreateSelection() sel.SelectPart(u"IPM/rotor-1") folderPath = getFolderPathOfOpenedProjectFile() fileName = u"MagneticFluxDensity.csv" outputFullPath = os.path.join(folderPath, fileName) # テーブルの出力形式は以下から選択可能。 # designer : JMAG-Designer形式でテーブルを出力 # studio : 旧JMAG-Studio形式でテーブルを出力 study.ExportTable(tableDefinition, outputFullPath, "designer")