# Copyright (c) 2026 JSOL CORPORATION # # 本スクリプトはMITライセンスのもとで公開しています。 # ライセンス全文は以下を参照してください。 # https://www.jmag-international.com/jp/scriptlibrary/jmag_script_library_mit/ import os app = designer.GetApplication() def createLamiMagFluxDensityProbe(study, title): """磁束密度(積層)のプローブを作成する""" probe = study.CreateProbe(title) probe.SetAutoRecalculate(False) probe.SetResultType(u"LaminationMagneticFluxDensity") # The 1st argument of SetResultCoordinate # 名称かインデックス # プリセット座標系の名称は言語設定に従って固定 # インデックスはプロジェクト-モデル-座標系の下にある座標系定義から0ベースで指定 probe.SetResultCoordinate(0) # probe.SetResultCoordinate(u"直交座標系(全体)") probe.SetComponent(u"All") probe.SetLocationCoordinate(0) # probe.SetLocationCoordinate(u"直交座標系(全体)") probe.SetProbeType(u"Coordinate") probe.SetLocation(0, u"-58", u"9", u"0") probe.RenamePoint(0, u"Measurement position") probe.SetUseElementValue(True) probe.SetMoveWithPart(True) probe.Build() return probe def createAvgVsDepth(dataManager, probe, param): """深さごとの平均に必要なパラメータを作成する""" parameter = app.CreateGraphIntegralParameter(param[u"title"]) dataSet = probe.GetDataSet() parameter.AddDataSet(dataSet) parameter.SetMin(param[u"min"]) parameter.SetMax(param[u"max"]) parameter.SetRangeUnit(param[u"rangeUnit"]) dataSetAVGVsDepth = dataManager.CreateAverageVersusDepth(parameter) graphModelAVGVsDepth = dataManager.CreateGraphModel(dataSetAVGVsDepth) return graphModelAVGVsDepth def getFolderpathOfOpenedProjectFile(): """開かれているjprojファイルのフォルダのパスを取得する""" openedJprojFilePath = app.GetProjectPath() folderPath = os.path.dirname(openedJprojFilePath) return folderPath def exportAvgVsDepth(graphModelAVGVsDepth, exportPath): """深さごとの平均をエクスポートする""" graphModelAVGVsDepth.WriteTable(os.path.join(exportPath, u"avgVsDepth.csv")) study = app.GetCurrentStudy() probeTitle = u"B-lamination" probe = createLamiMagFluxDensityProbe(study, probeTitle) dataManager = app.GetDataManager() dataSetTitle = u"B-lamination AVG" param = { u"title" : dataSetTitle, u"min" : u"0", u"max" : u"0.02", u"rangeUnit" : u"s" } graphModelAVGVsDepth = createAvgVsDepth(dataManager, probe, param) exportPath = getFolderpathOfOpenedProjectFile() exportAvgVsDepth(graphModelAVGVsDepth, exportPath)