Professional Documents
Culture Documents
JFT165ScriptEditortoJMAG e
JFT165ScriptEditortoJMAG e
JFT165ScriptEditortoJMAG e
Contents
Overview........................................................................................................................................ 2
1 Function Description ................................................................................................................... 2
1.1 Importing to JMAG-Designer ............................................................................................... 2
1.2 Automatically Recording The Script ..................................................................................... 2
2 Procedures ................................................................................................................................. 3
2.1 Starting the Script Editor ...................................................................................................... 3
2.2 Setting the Environment Variables....................................................................................... 3
2.3 Starting JMAG-Designer ...................................................................................................... 4
2.4 Loading the Model ............................................................................................................... 4
2.5 Setting the Script Language ................................................................................................ 4
2.6 Automatically Recording The Script ..................................................................................... 5
2.7 Editing the Script .................................................................................................................. 6
2.8 Running the Script ............................................................................................................... 7
2.9 Checking the Settings .......................................................................................................... 8
Appendix A How to Always Start a New Process ...................................................................... 9
Appendix B Input Assist Function for Scripts ........................................................................... 10
Overview
Although one way of improving analysis efficiency is to automate JMAG operations by using
scripts, developing the scripts can be time consuming. JMAG can be operated from an external
development environment by using Python scripts. Scripts can also be developed by using a
third-party integrated development environment which increases the efficiency of script
development. By using a third-party integrated development environment, you can develop
scripts while also checking the console output, and variable displays, etc.
This document explains how to run a Python script on a third-party integrated development
environment, then configure the settings for conditions in JMAG.
1 Function Description
This explains the function used in this document.
2
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
2 Procedures
In this document, the operation for setting a current condition in JMAG-Designer is recorded as
a script. This script is then run in a third-party integrated development environment to check that
the current condition has indeed been set in JMAG-Designer.
The version of JMAG-Designer is specified via PYTHONPATH. In addition, a JMAG-Designer
module is imported for running from the external development environment.
<Preconditions>
The following environment is required for this tutorial.
Versions of Python 3 are required to run the script.
You can use either Python libraries that are already installed on the machine that you are
using, or the Python libraries that are installed together with JMAG-Designer.
1. Start Spyder.
1. Select [Tools] > [PYTHONPATH manager] from the Spyder menu bar.
The [PYTHONPATH manager] dialog box is displayed.
2. Click [Add path].
The [Select directory] dialog box is displayed.
3. Open the JMAG-Designer installation folder.
This is installed in "C:¥Program Files¥JMAG-Designer22.0" by default.
4. Click [Select Folder].
The path to the JMAG-Designer installation folder is added.
5. Click [OK].
The [PYTHONPATH manager] dialog box closes.
3
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
1. Start JMAG-Designer.
4
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
1. Select [Scripts] > [Start Recording] from the JMAG-Designer menu bar.
The automatic recording of the script starts, and [Recording] is displayed in the toolbar.
2. Click the [Conditions] tab in the [Toolbox].
The [Toolbox] switches to a display of a list of conditions.
3. Click the [Current] condition under [Current].
4. Drag this to a part in the graphics window.
The [Current] setting panel opens. [Square] is displayed under [Parts].
5. Click [OK].
The [Current] setting panel closes. [Current] is added under [2D Model] > [Study] >
[Conditions].
6. Select [Script] > [Stop Recording] from the menu bar.
The automatic recording of the script ends, and the [Script Editor] dialog box is displayed.
The script for setting the current condition has now been recorded (Fig. 2-6-1).
7. Right-click [Current] under [2D Model] > [Study] > [Conditions] in the [Project Manager]
tree.
8. Select [Delete] from the context menu.
[Current] is deleted from under [2D Model] > [Study] > [Conditions] (Fig. 2-6-2).
9. Ensure that JMAG-Designer remains displayed.
2 app = designer.GetApplication()
4 app.GetModel(u"Simple").GetStudy(u"Static").GetCondition(u"untitled 1").ClearParts()
6 sel.SelectPart(4)
7 app.GetModel(u"Simple").GetStudy(u"Static").GetCondition(u"untitled 1").AddSelected(sel)
5
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
1. Enter "from jmag.designer import *" (the red frame displayed in Fig. 2-7-1) into the
Spyder editor.
2. Copy and paste the script that was recorded in Step 2.6.
3. Check that the recording is the same as Fig. 2-7-2.
11 app.GetModel(u"Simple").GetStudy(u"Static").GetCondition(u"untitled 1").ClearParts()
13 sel.SelectPart(4)
14 app.GetModel(u"Simple").GetStudy(u"Static").GetCondition(u"untitled 1").AddSelected(sel)
6
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
Title].
7
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
1. Display JMAG-Designer.
2. Check that [Current] is set under [2D Model] > [Study] > [Conditions] in the [Project
Manager] tree (Fig. 2-9-1).
3. Right-click [Current].
4. Select [Edit] from the context menu.
The [Current] setting panel opens.
5. Check that a part is added under [Parts].
END
8
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
3 app = designer.CreateApplication()
4 app.Load(u"D:¥JFT165ScriptEditortoJMAG-01.jproj")
6 app.GetModel(u"Simple").GetStudy(u"Static").GetCondition(u"untitled 1").ClearParts()
8 sel.SelectPart(4)
9 app.GetModel(u"Simple").GetStudy(u"Static").GetCondition(u"untitled 1").AddSelected(sel)
9
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
10
JFT165-01e
JMAG Function Tutorial - Running JMAG Using a Python Development Environment -
URL https://www.jmag-international.com/tutorial/
JSOL Corporation
jmag-support@sci.jsol.co.jp
Technical Support
or
A distributor in your country
11
JFT165-01e