# Copyright (c) 2026 JSOL CORPORATION
#
# 本スクリプトはMITライセンスのもとで公開しています。
# ライセンス全文は以下を参照してください。
# https://www.jmag-international.com/jp/scriptlibrary/jmag_script_library_mit/

app = designer.GetApplication()

def createEquationForCaseControl(designTable, varName, type, expression):
    """ケースコントロールに方程式を作成する。"""
    designTable.AddEquation(varName)
    equation = designTable.GetEquation(varName)
    # 方程式のタイプ
    # 0:値
    # 1:式
    # 2:式（条件）
    # 3:式（フラグ）
    equation.SetType(type)
    equation.SetExpression(expression)
    equation.SetModeling(False)
    equation.SetDisplayName(u"result_check")
    equation.SetDescription(u"Use to compare results.")
    equation.SetDisplayIndex(0)

study = app.GetCurrentStudy()
designTable = study.GetDesignTable()
type = 1
varName = u"Delta1"
expression = u"abs(cos(45/90))"
createEquationForCaseControl(designTable, varName, type, expression)
