My DocBlock Data doesn't update programmatically

조회 수: 4 (최근 30일)
Lucas S
Lucas S 2020년 4월 29일
댓글: Lucas S 2020년 5월 6일
Hello !
I have created a DocBlock in my model and i would like to update the content programmatically. I have this code :
DocBlock = find_system('Model', 'SearchDepth', 1, 'Name', 'DocBlock');
DocBlockHandle = getSimulinkBlockHandle(DocBlock);
B = get_param(DocBlockHandle, 'UserData');
B.content = 'Test DocBlock update';
set_param(DocBlockHandle, 'UserData', B, 'UserDataPersistent','On');
save_system('Model');
When i debug, B is updated with the good content but when i run the script and i enter in my DocBlock .txt file it didn't changed i don't understand why.
EDIT : When i change directly the text of the .txt file it saves the changes but still not when i use script
Thank you !

채택된 답변

omar Elkawokgy
omar Elkawokgy 2020년 5월 6일
편집: omar Elkawokgy 2020년 5월 6일
The problem in DocBlock file that it creates a temp .txt in temp folder, so what you need to do is delete this files before editing programmatically. There is a command in DeleteFcn in callbacks of the DocBlock itself called "docblock('close_document', gcb);". All you need to do is add this line to your code before calling set_param command like so:
DocBlock = find_system('Model', 'SearchDepth', 1, 'Name', 'DocBlock');
DocBlockHandle = getSimulinkBlockHandle(DocBlock);
B = get_param(DocBlockHandle, 'UserData');
B.content = 'Test DocBlock update';
docblock('close_document', DocBlockHandle);
set_param(DocBlockHandle, 'UserData', B, 'UserDataPersistent','On');
save_system('Model');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by