Create a Custom Block Library
This example illustrates how you can convert a namespace containing 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 folder structure:
- +MySimscapeLibrary |-- +MechanicalElements | |-- lib.m | |-- lib.jpg | |-- inertia.ssc | |-- spring.ssc |-- +ElectricalElements | |-- ... |-- +HydraulicElements | |-- ...
This means that you have a top-level namespace called
+MySimscapeLibrary
, which contains three subnamespaces,
+MechanicalElements
, +ElectricalElements
, and
+HydraulicElements
. The +MechanicalElements
namespace 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
sscbuild MySimscapeLibrary;
the top-level namespace generates a library model called
MySimscapeLibrary_lib
, as follows:
Notice that the sublibrary generated from the +MechanicalElements
namespace 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: