[S0059] Create a scaling factor

The displacement is reflected in the mesh and plot displays following the analysis.
The visual representation of the analysis results can be adjusted by setting a scaling factor for the displacement.
For instance, if the actual displacement is very small and the deformation is difficult to discern, adjusting the scale factor makes it easier to visually identify minute changes and distribution trends.
This script creates an equivalent scaling factor across all components.

Preconditions

  • One or more studies that supports scaling factor have been created.
    Studies supporting scaling factor: magnetic field analysis, structural analysis, thermal stress analysis
    This script runs on the active structural analysis study in the project tree.
  • To display the defined vector plot, the study has been calculated.

Script Function

  • Create a scaling factor
    Set the scaling factor to 1.25 as all axes equivalent.
  • Create a vector plot
    Create a displacement vector plot.
    Configure the settings to apply the previously created scaling factor when displaying the vector plot.
    Configure the settings to overlay the original model.
  • Turn on display the defined vector plot
# 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/

app = designer.GetApplication()

def createScaling(study, param):
    """Set the magnification to apply to the plot (scale setting)"""
    scaFac = study.CreateScaling(param[u"title"])
    scaFac.SetScalingFactor(param[u"scalingFactor"])

def createVector(study, paramVector):
    """Create a vector plot with scale applied and configure the display settings."""
    vectorDefinition = study.CreateVector(paramVector[u"title"])
    vectorDefinition.SetResultType(paramVector[u"resultType"])
    vectorDefinition.SetPlace(paramVector[u"place"])
    vectorDefinition.SetViewScale(paramVector[u"viewScale"])
    vectorDefinition.SetScalingFactor(paramVector[u"scalingFactor"])
    # display type
    # 0:Shaded
    # 1:Hidden Line
    # 2:Wireframe
    vectorDefinition.SetDisplayType(paramVector[u"displayType"])
    vectorDefinition.SetViewOriginalModel(paramVector[u"viewOriginalModel"])

study = app.GetCurrentStudy()
paramScale = {
    u"title" : u"SingleScale",
    u"scalingFactor" : 1.25
}
createScaling(study, paramScale)
paramVector = {
    u"title" : u"DispVecSingleScale",
    u"resultType" : u"Displacement",
    u"place" : u"SurfaceNodes",
    u"viewScale" : True,
    u"scalingFactor" : study.GetPostCondition(paramScale[u"title"]),
    u"displayType" : 2,
    u"viewOriginalModel" : True
}
createVector(study, paramVector)

# Turn on the display of the vector result.
view = app.View()
view.SetVectorView(True)

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