I want to create a project file in the folder where the script is located using a script.
The JMAG-Designer script editor cannot obtain the relative path of the script file.
Therefore, it must be executed in the user's Python environment.
The following is an example of a Python script.
To execute this script, you must first configure JMAG-Designer to be controlled from the user's Python environment.
The procedure for configuring JMAG-Designer varies depending on the environment, so please refer to the [JMAG-Designer Help (JMAG Script Help)] for details.
This sample has been verified to work in the following environments.
・JMAG-Designer V24.1.01zh
・Spyder version: 6.0.7
# -*- coding: utf-8 -*-
import os
from pathlib import Path
from jmag.designer import designer
#Get the path where the Python script is located
workpath = Path('.').resolve()
#Launch JMAG-Designer in non-GUI mode and output a log file
app = designer.CreateApplication(option=['-g','-l',str(workpath) + u"/log.txt"])
#Create a project file in the folder where the script is located
app.SaveAs(str(workpath) + u"/test.jproj")
#Exit JMAG-Designer
app.Quit()
*Note
When you run a script in the JMAG-Designer script editor, the project file and log file are created in the JMAG installation folder, not in the folder where the script is located.


