Create a Custom Block Library
This example illustrates how you can convert a package of Simscape™ component files into a custom block library, containing sublibraries with customized names and appearance. It summarizes the techniques described in Organizing Your Simscape Files, Converting Your Simscape Files, and Customizing the Library Name and Appearance.
Consider the following directory structure:
- +MySimscapeLibrary |-- +MechanicalElements | |-- lib.m | |-- lib.jpg | |-- inertia.ssc | |-- spring.ssc |-- +ElectricalElements | |-- ... |-- +HydraulicElements | |-- ...
This means that you have a top-level package called
+MySimscapeLibrary
, which contains three subpackages,
+MechanicalElements
, +ElectricalElements
, and
+HydraulicElements
. The +MechanicalElements
package contains two component files, inertia.ssc
and
spring.ssc
, a library icon file lib.jpg
, and
the following library configuration file lib.m
:
function lib ( libInfo ) libInfo.Name = 'Basic Mechanical Elements'; libInfo.Annotation = sprintf('This library contains basic mechanical elements'); libInfo.ShowName = true;
When you run
ssc_build MySimscapeLibrary;
the top-level package generates a library model called
MySimscapeLibrary_lib
, as follows:
Notice that the sublibrary generated from the +MechanicalElements
package is presented in its parent library with a customized icon and name
(Basic Mechanical Elements
).
If you double-click the Basic Mechanical Elements sublibrary, it opens as follows: