How can I migrate enumerated data types between data dictionaries?

I am rearchitecturing the data dictionaries (DD) of my model. the way that worked for me is opening each individual DD and use
exportToFile(sectionObj,fileName)
to export data to a .m file , then run all the files to load data into base workspace, and use the following command
importFromBaseWorkspace(myDictionaryObj, 'existingVarsAction','overwrite');
to import them into the new DD.
the mothod works fine for all data types except enumerted data type definitions (aka 'Simulink.data.dictionary.EnumTypeDefinition').
the question is a way to transfer the enumerted data type definitions between data dictionaries using a script (for reproduction)?
note I am using R2020b

 채택된 답변

adham
adham 2023년 10월 18일
I solved the problem by changing the medthod to iterating over all old DDs, fetching their entries and adding them to the new one while both source and destination DDs are open
allEntries = find(DataSecObj_source);
for j=1:length(allEntries)
if ~exist(DataSecObj_destination,allEntries(j).Name)
addEntry(DataSecObj_destination,allEntries(j).Name,getValue(allEntries(j)));
end
end
saveChanges(mainDD_Obj)
Simulink.data.dictionary.closeAll(DDObj_source,'-discard')
this method transfer all the objects icluding enum data type defintions without the need for an intermediate stage of .m or .Mat files.

댓글 수: 1

this seamed more intuitive but it did not work with me the first time so I thought about the other method mentioned in the question itself,m hopfully the thread is useful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Manage Design Data에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2023년 10월 15일

댓글:

2023년 10월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by