How can we use find_system to get a block's SID

In this page of the Matalb's documentation, it is said not to use the Simulink.ID.getSID() command and use find_system instead.
I have trouble understanding how to use find_system in order to replace this command.
I would also like to know why using Simulink.ID.getSID() is not recommanded.
Regards,
P Lepage.

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 9월 29일

0 개 추천

It is true that find_system() is not the real replacement. If full block path is used in Simulink.ID.getSID() to get SID, then the replacement should be get_param(FullBlockPath, 'SID'). find_system might be used to find the block first.
Looking at the warning message in document for Simulink.ID.getSID, Simulink.ID.getHandle and Simulink.ID.hilite, I assume Mathworks is phasing out the Simulink.ID sub-class.

댓글 수: 5

The thing I dont like with get_param(FullBlockPath, 'SID') is that is does not returns a SID path. You have to strcat(modelName, ':' , SID).
And as you said, find_system is useful when you don't have block paths.
When you do have them, there dosen't seem to be a recommended way to convert them to SID path.
I can see the need for SID when doing model diff. I have not found any other use case for it. For me, the full block path and the handle are sufficient.
The "ModelName:" prefix is the same for all the blocks in the model, that is why the "SID" property only records the numerical number.
Yeah i'm using SID path to deal with object that may change name in a model that may be closed. I get why SID feild is only the SID number, I just wish there was a clean way to get the SID path.
When would the SID path (ModelName:SID) be used? If I know the SID number, I would do find_system(Model,'SID',###).
They are stored in a map to have a reference that does not depend on block's name. This map is then used to hilite_system the block it contains through callbacks and generated html documents.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

질문:

2020년 9월 28일

댓글:

2020년 10월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by