Get number of hierarchy levels in block path



length = getLength(bp) returns a numeric value that corresponds to the number of levels in the model reference hierarchy for the block path.


collapse all

Create a Simulink.BlockPath object that represents a referenced model within a model hierarchy.

bp = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...
'sldemo_mdlref_heater/Fahrenheit to Celsius'});

Get the number of hierarchy levels in the block path for the Simulink.BlockPath object.

length = getLength(bp)
length =


Input Arguments

collapse all

Fully specified block path, specified as a Simulink.BlockPath object. This block path uniquely identifies a block within a model hierarchy, even when the model hierarchy references the same model multiple times.

Output Arguments

collapse all

Length of the block path, returned as an integer. The length is the number of levels in the model reference hierarchy.

Introduced in R2010b