Creating blocks in Plecs with scripts

Thanks for clarifying Kristian - it helped me better understand your goals.

There isn’t a similar script-based interface to add blocks to a schematic. However, once the block is added to the schematic, the C-Script fields are all configurable as parameters.

For example:

% Set command convention: plecs('set', 'componentPath', 'parameter', 'value')

DeclarationString = "#include <math.h>
";
plecs('set','./PathToScript/C-Script','Declarations',DeclarationString)

For many components in PLECS, you can determine the parameter name by clicking the check-box near the parameter entry or in the component mask editor window. The parameter name for each field in a C-Script may not be obvious (e.g. ‘Declarations’, ‘StartFcn’, ‘OutputFcn’, etc.). PLECS Standalone files are plain-text. By reviewing the portion of the model describing the C-Script the various parameter names will be apparent.

Since the PLECS Standalone file is plain text, one can also programatically construct a model by writing the appropriate text strings, which I have done in the past. Note that the file format is subject to change in future versions of PLECS.