[S8350] Script for importing CSV files with conditions, circuits, and materials

 

The following is an example of a script that reads CSV files  on conditions, circuits, and materials.

# Please prepare your own CSV files.

app = designer.GetApplication()

# Ex 1) Current conditions

# Select Current conditions

Cond = app.GetModel(0).GetStudy(0).GetCondition(u"Current Condition name")

# Specify the type of X-axis

Cond.SetValue(u"XType", u"Time")

# Specify the function type

Cond.SetValue(u"FunctionType", u"Table")

# Reading CSV files

Cond.SetTableFromFile(u"Time", u"D:/sampleA.csv")
# Ex 2) Current source component

# Selecting a current source component

Comp = app.GetModel(0).GetStudy(0).GetCircuit().GetComponent(u"Current Source (1 terminal) Component name")

# Specify the type of X-axis

Comp.SetValue(u"XType", u"Time")

# Specify the function type

Comp.SetValue(u"FunctionType", u"PointArray")

# Reading CSV files

Comp.SetTableFromFile(u"Time", u"D:/sampleB.csv")
# Ex 3) Material (BH curve)

# Select materials

bhtable = app.GetMaterialLibrary().GetUserMaterial(u"Material name")

# Specify the type of magnetic property

bhtable.SetValue(u"MagneticSteelPermeabilityType", u"BHCurve")

# Reading CSV files

bhtable.GetTable("BhTable").ReadFromFile(u"D:/sampleC.csv")

How to use script file

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