Documentation Center

  • Trial Software
  • Product Updates

sl_postprocess

Make postprocessing customizations when building custom block library

Syntax

sl_postprocess(h)

Description

sl_postprocess(h) takes a handle to the custom block library, h, and allows you to make library postprocessing customizations (for example, add a forwarding table).

If a Simscape™ file package being built contains a sl_postprocess.m file, then ssc_build calls sl_postprocess once the block library (package_name_lib) is generated but before it is saved to disk. If sl_postprocess generates an error, the library does not build.

You can include a sl_postprocess.m file at any level in the library package. At the top level, it makes postprocessing changes to the whole custom block library. Similarly, if the sl_postprocess.m file resides in a sublibrary in the package, it takes a handle to that sublibrary and makes the corresponding changes.

Examples

Consider the following directory structure:

- +MySimscape 
|-- +Mechanical 
| |-- spring.ssc 
| |-- ...

For example, you have restructured your custom Mechanical library to have two sublibraries, Rotational and Translational, and moved the spring block to the Rotational sublibrary. To update old models that reference the block, you need to add a forwarding table.

Instead of manually adding a forwarding table, which will get overwritten every time you rebuild the library, you can include a sl_postprocess.m file in the library package, which will add the forwarding table automatically upon rebuilding the library:

- +MySimscape 
|-- sl_postprocess.m 
|-- +Mechanical 
| |-- +Rotational
| | |-- spring.ssc 
| | |-- ... 
| |-- +Translational
| |-- ...

The sl_postprocess.m file contains a forwarding table:

function sl_postprocess(h)
% Forwarding table for the spring block
ft = { {'MySimscape_lib/Mechanical/spring', 'MySimscape_lib/Mechanical/Rotational/spring'} }
set_param(h, 'ForwardingTable', ft);
end

Note that if you have customized the library names (using lib.m files) or the block name, you have to use these custom names in the forwarding table (for example, 'Rotational Spring' instead of 'spring').

See Also

Was this topic helpful?