Is there's any way to get handles of all selected block using simulink APIs ?
Suppose I select few blocks using mouse, how could I get handles of all selected blocks in form of an array or cells using simulink APIs ?
With gcbh it just gives the handle of recently selected block only.
Basically I want to auto-generate corresponding "From" blocks of all selected "Goto" Blocks and vice-versa.
Matlab Version : 2010b
This gives you the names of all the selected blocks:
blockNames = find_system('Type', 'Block', 'Selected', 'on')
You should be able to obtain the handle to the blocks by iterating over the cell array and calling get_param(blockName, 'handle'):
for i = 1:length(blockNames)
blockHandles(i)= get_param(blockNames{i},'handle');
end
This doesn't answer the question directly, but if you want to auto-generate "From" blocks, I suggest the following from the File Exchange:
http://www.mathworks.co.uk/matlabcentral/fileexchange/40117-autofromtag
I have used it before and it works very well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With