Hi all
I created a matlab script that extracts all the block paths and names from a simulink model to save them in an excel file in order to translate them. After the translation I read the excel file and with the same path and based on the old name I`m trying to push the new names to the simulink model. It works, but occasionally it gives me an error regarding a block that the script can`t find, which is allready there, sometimes its name was the latest one that was changed.
Here is the code that I`m using:
addpath(genpath("Path"));
[num,txt,raw] = xlsread('Excel_name', 'Excel_sheet');
clean_path = strrep(txt{i,path_coll}, '//', '//');
raw_name = strrep(txt{i,old_nm_coll}, '//', '/');
root_path = strrep(clean_path, raw_name, '');
new_path = strcat(root_path, txt{i,new_nm_coll});
if getSimulinkBlockHandle(new_path) ~= -1
disp(['The block "',txt{i,new_nm_coll}, '" is already renamed.'])
elseif getSimulinkBlockHandle(clean_path) ~= -1
set_param(txt{i,2},'Name',txt{i,new_nm_coll});
disp(['The block "',txt{i,old_nm_coll},'" was renamed to "',txt{i,new_nm_coll},'".'])
disp(['No block called "',txt{i,old_nm_coll}, '" or "',txt{i,new_nm_coll},'" could not be found.'])
open_system(root_path, 'force');
And here is the error that stops all:
The block "Old_name_1" was renamed to "New_name_1".
The block "Old_name_2" is already renamed.
The block "Old_name_3" was renamed to "New_name_3".
No block called "Old_name_3" or "New_name_3" could not be found.
Error using Auto_block_name_corrector (line 40)
Block 'Simulink_path/Old_name_3' not found in block diagram 'Simulink_nodel_name'.
Please help!