As a workaround, you can try programmatically searching for the number of instances of a library by following the example mentioned below:
expLib = load_system('example.slx');
expLibBlocks = find_system(expLib, 'LookUnderMasks', 'all', 'Type', 'Block');
blockTypeArray = get(expLibBlocks, 'BlockType');
To count the number of occurances, you can use the following function. Please note that if you're using a custom library block, this function will not be able to count the occurrences of its subsystem.
function count = countStringOccurrences(cellArray, searchString)
for i = 1:length(cellArray)
if ischar(cellArray{i}) && strcmp(cellArray{i}, searchString)
Here's an example of the "countStringOccurrences" function being used.
numOfOccurences = countStringOccurrences(blockTypeArray, 'Outport')
To programmatically find the path of a library block in a model, you can use the following code snippet:
pathOfTheBlock = get(find_system(ex, 'Name', 'Outport')).Path
I hope this helped, thanks!