How to migrate legacy CADFEKO Lua scripts to the new CADFEKO API format


Use the ConvertLuaScript utility to migrate legacy CADFEKO Lua scripts to the latest CADFEKO API format.

 

Migration is only applicable to CADFEKO Lua scripts created prior to version 2022.1 (it is not applicable to POSTFEKO scripts).

 

 Instructions

  1. Download the attached utility for your system (available for Microsoft Windows and Linux) and save the executable (ConvertLuaScript) file to disk.
  2. Read the README.txt (included in the .zip folder) for instructions on how to run the utility on your platform.

 

Command line options:

ConvertLuaScript.exe [-h] [--directory DIRECTORY] [--filename FILENAME]

 

Options:

--directory DIRECTORY

Directory or path containing the Lua files which use legacy CADFEKO syntax that should be converted. All files with a '*.lua' extension will be converted in the selected path and all subdirectories below this path will be processed. Files with a *.lua_backup extension will be ignored and not overwritten.

--filename FILENAME

Filename (absolute or relative path) of a Lua file using legacy CADFEKO syntax that is to be converted.

 

Summary of CADFEKO API Changes

The following is a list of the CADFEKO API changes (but not limited to):

 

Changed .GetApplication() to .getInstance() for cf Namespace

For the CADFEKO namespace, changed the function .GetApplication() to .getInstance().
For example, change the legacy API from:

app = cf.GetApplication()

to

app = cf.Application.getInstance()

 

Simplifying Geometry

When simplifying geometry, geometry parts are now added as a ChildReferences list to the properties table.
For example, change the legacy API from:

geomCollection = {geometryObject[1], geometryObject[xx]}

for xx = 1, #geomCollection do

project.Geometry:Simplify(geomCollection[xx],properties)

end

to

properties.ChildReferences[1] = geometryObject[1]

properties.ChildReferences[xx] = geometryObject[xx]

arraySimplified = project.Contents.Geometry:Simplify(properties)

 
Adding a Source, Load or General Network to a Port

For sources (current source, FEM modal source, voltage source and waveguide source), and loads (complex, series, Touchstone and SPICE circuit), the property Terminal changed to Port.


For example, change the legacy API from:

properties.Terminal = project.Contents.Ports[portLabel]

to

properties.Port = project.Contents.Ports[portLabel]

 

Adding an S-Parameter Configuration

The SParameter object now has the property PortProperties. As a result, the following properties of PortProperties:

must migrate to the new CADFEKO API.

For example, change the legacy API from:

properties = cf.SParameterConfiguration.GetDefaultProperties()

properties.PortProperties[portElement].Impedance = "50"

properties.PortProperties[portElement].Terminal = project.Ports[portLabel].Terminal

to

properties = cf.SParameterConfiguration.GetDefaultProperties()

properties.SParameter.PortProperties[portElement].Impedance = "50"

properties.SParameter.PortProperties[portElement].Terminal =

project.Contents.Ports[portLabel]

 
Adding Frequency, Sources, Loads and Power

Added a global collection for frequency, sources, loads and power specified globally. For example, GlobalFrequency, GlobalSources, GlobalLoads and GlobalPower.


For example:

properties = cf.VoltageSource.GetDefaultProperties()

properties.Terminal = project.Ports["Port1"].Terminal

properties.Label = "VoltageSource1"

voltageSource1 =

application.Project.Contents.SolutionConfigurations.GlobalSources:AddVoltageSource(properties)

 

If you have any questions, please contact Altair support.