[S8447] Script to add a case with modified design parameters including geometry dimensions.

 

I want to add a case and change design parameters including geometry dimensions with a script.

There are primarily two methods for changing design parameters:

 (A) When the Parameter Index is known

 (B) When the Parameter Index is unknown, automatically detect the Index from the variable name

An example Python script combining (A) and (B) is as follows:

This sample performs the following parameter settings:

 ・(Method A) Changes the variable value corresponding to ParameterIndex=0 to “10”

 ・(Method B) When the current amplitude is denoted as Iamp, changes it to 15A

Since setting conditions differ per model, this sample cannot be executed as-is.

Modify the parameter settings to match your specific model.
# -*- coding: utf-8 -*-

app = designer.GetApplication()

#If a CAD link has not been established, establish one.

if app.GetCurrentModel().IsCadLinkOpen() == 0:

  app.GetCurrentModel().RestoreCadLink()

#Add a case

app.GetCurrentStudy().GetDesignTable().AddCase()

#Retrieving the added case ID

IdxCase = app.GetCurrentStudy().GetDesignTable().NumCases() - 1

#Set the parameters of the added case with the SetValue function. Arguments are (case ID, parameter ID, set value)

### Pattern (A) method (when Parameter Index is 0 and known)

app.GetCurrentStudy().GetDesignTable().SetValue(IdxCase, 0, 10) #Change the value of variable ParameterIndex=0 to 10

### Pattern (B) method (Obtain parameter index from variable name “Iamp”)

parameterIndex = app.GetCurrentStudy().GetDesignTable().GetParameterIndex(u"Iamp")

### Pattern (B) method (Set parameters for the added case based on the parameter index obtained above)

app.GetCurrentStudy().GetDesignTable().SetValue(IdxCase, parameterIndex, 15) #Change the value of variable Iamp to 15

#Show added cases

app.View().SetCurrentCase(IdxCase + 1)

#overwrite save

app.Save()

 
*Note 

・Design variables must be registered before script execution.

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.