[S0050] Create an arc section graph and obtain the result

A section graph extracts the distribution of a result value along a specified section in model space and displays it as a graph plotted against position.
Sections can be defined as either straight lines or circular arcs depending on the direction of evaluation.
Because the configuration settings for section graphs are complex, there are several points to consider when defining them via script.
A straight line or a circular arc is distinguished through specific API calls. This script creates an arc section because `SetArcExpression` is called; calling `SetLineExpression` would create a straight-line section. The last method called takes precedence.
The `SetAirRegionFlag` allows to choose between a normal section and an arbitrary region section. To create an arbitrary region, call this method with the argument set to `True` after specifying the result type.
Due to the large number of parameters and their interdependencies, the `Build` needs to be called at the end. This generates the section graph based on the configured settings.
This script creates a section graph that displays result values ​​along a circular arc.

Preconditions

  • One or more studies have been created.
    This script runs on the active structural static analysis study in the project tree.

Script Function

  • Create a section graph
    Set result type to mises stress.
    Set abscissa axis to the angle.
    Define the arc for the section graph by center axis direction, a point on the center axis, the start point, the radius and the arc angle.
  • Build the section graph.
  • If the study has results, display the value table for the created section graph.
# 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()
graphNm = u"targetSectionArc001"

def createArcGraphForSection(study, params):
    """Create a new arc graph for the section."""
    sectionGraph = study.CreateSectionGraph(graphNm)
    sectionGraph.SetResultType(params["resultType"], params["sourceTitle"])
    sectionGraph.SetAbscissa(params["abscissa"])
    sectionGraph.SetArcExpression(params["arcExpression"]["originX"], params["arcExpression"]["originY"], params["arcExpression"]["originZ"],
                                  params["arcExpression"]["axisX"],   params["arcExpression"]["axisY"],   params["arcExpression"]["axisZ"],
                                  params["arcExpression"]["startX"],  params["arcExpression"]["startY"],  params["arcExpression"]["startZ"],
                                  params["arcExpression"]["angle"],   params["arcExpression"]["radius"])
    sectionGraph.Build()
    return sectionGraph

def outputResultSet(sectionGraph):
    """Log the section's dataset."""
    dataSet = sectionGraph.GetDataSet()
    header = f"{dataSet.GetXAxisTitle()}, {dataSet.GetYAxisTitle()}"
    print(header)
    for i in range(dataSet.GetRows()):
        msg = f"{dataSet.GetValue(i, 0):13.10f}, {dataSet.GetValue(i, 1):13.10f}"
        print(msg)

study = app.GetCurrentStudy()
params = {
    "resultType"    : u"MisesStress",
    "sourceTitle"   : u"",
    "abscissa"      : u"angle",
    "arcExpression" : { "originX" : u"0",  "originY" : u"0", "originZ" : u"5",
                        "axisX"   : u"0",  "axisY"   : u"0", "axisZ"   : u"1",
                        "startX"  : u"26", "startY"  : u"0", "startZ"  : u"5",
                        "angle"   : u"90", "radius"  : u"26" },
}
sectionGraph = createArcGraphForSection(study, params)
if study.HasResult():
    outputResultSet(sectionGraph)

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