[S0051] Export project files with selecting studies

JMAG-Designer provides project export function to save selected specific models and studies.
This function also provides options regarding save version and saving with/without results, enabling file size reduction or project reuse tailored to needs.
This script exports the project with selected studies with results.

Preconditions

  • One or more models have been created.
    This script selects 3 studies.
  • The model name and study name to be exported are known.

Script Function

  • Specify "S0051.jproj" as the filename for the exported file.
  • Specify studies to be exported by the model name and study title.
  • Set the option to save results to True.
  • Set save version to 25.0.
  • Export the project file to the same folder as the currently open jproj file.
# 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 getFolderpathOfOpenedProjectFile():
    """Get folder path of opened jproj file"""
    openedJprojFilePath = app.GetProjectPath()
    folderPath = os.path.dirname(openedJprojFilePath)
    return folderPath

def projectExport(outputFullPath, exportTargetModelStudy, version):
    """Export the project"""
    prjExpParam = app.CreateProjectExportParameter()
    for modelName, studyName in exportTargetModelStudy:
        prjExpParam.AddStudy(modelName, studyName)
    # Whether to save results.
    # True:save
    # False:Don't save
    prjExpParam.SetSaveResults(True)
    prjExpParam.SetSaveVersion(version)
    app.ExportProject(outputFullPath, prjExpParam)

outputJprojName = u"S0051.jproj"
outputFullPath = os.path.join(getFolderpathOfOpenedProjectFile(), outputJprojName)
exportTargetModelStudy = [
    # model name、study_title
    [u"2D_PM_motor", u"2D_PM_motor"],
    [u"2D_PM_motor", u"2D_PM_motor_load"],
    [u"2D_PM_motor", u"2D_PM_motor_parametric"],
]
version = 25.0
projectExport(outputFullPath, exportTargetModelStudy, version)

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