[S0008] Get the applied conditions by specifying the analysis condition type name

 

To get condition objects from the analysis study to refer or update, it’s best to assign them a recognizable title beforehand, but this isn’t always done. On the other hand, many condition types are applied only once per study. This script retrieves the conditions applied to a study by specifying the condition type name.

Preconditions

  • One or more studies must have been created.
    This script is run for the active study in the project tree.
  • If there are multiple conditions of the same type, all can be retrieved, but to distinguish between them, a recognizable title or other identifying information must be known.

Script Function

  • Specify the name of type “RotationMotion” for the rotation motion condition and retrieve all applied rotation motion conditions. The name of type is independent of the language setting.
  • Display the ID of the part to which the rotation motion condition is applied.
  • Display the property values ​​of the rotation motion condition. This script displays the displacement type and constant rotation speed.
# 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/


def getConditionsSpecifiedType(targetStudy, typeName):
    """Get specified type conditions applied to the target study"""
    matches = []
    numConds = targetStudy.NumConditions()

    for i in range(numConds):
        condition = targetStudy.GetCondition(i)
        CondType = condition.GetScriptTypeName()
        if CondType == typeName:
            matches.append(condition)
    return matches

def checkRotationMotionPropertyValues(conditions):
    """Print some properties and values of rotation motion conditions"""
    for cond in conditions:
        if cond.GetScriptTypeName() == u"RotationMotion":
            print(cond.GetType(), u"; name:", cond.GetName(), u"; Applied parts IDs", cond.GetParts())
            proplist = conditions[0].GetPropertyNames()
            for name in proplist:
                if name == u"AngularVelocity":
                    print(cond.GetPropertyHelp(name), u":", cond.GetValue(name))
                elif name == u"MotionGroupType":
                    print(cond.GetPropertyHelp(name), u":", cond.GetFlagAsString(name))
            print(u"")


app = designer.GetApplication()
conditions = getConditionsSpecifiedType(app.GetCurrentStudy(), u"RotationMotion")
if len(conditions) <= 0:
    print(u"Specified condition is not found.")
else:
    checkRotationMotionPropertyValues(conditions)

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