unable to programmatically find lines inside a custom library-block

4 次查看(过去 30 天)
Hello,
I'm currently working on getting my subsystem to work as part of a library. This subsystem has a mask and modifys itsself: upon request old blocks and lines are deleted and new ones are placed. This works fine as long as I use it as a non-library block or I strip the part which connects the blocks. Somehow the command does not work inside a library block and therefore I get errors when the blocks should get connected to already existing lines (e.g. an already connected output-port can't take another signal).
I'm using the following command to search for all lines inside the library-block:
oldLines = find_system(gcb, 'FindAll', 'on', 'LookUnderMasks','all', 'type', 'line')
Since modifying the contents of a library-block only works inisde the initialization-function, I added a flag-parameter which allows me to update the contents only on request instead of all the events that trigger the function.
Is this behavior intended or is there another way to do this?
  1 个评论
Manuel K
Manuel K 2022-11-29
编辑:Manuel K 2022-11-30
I can however find the
'LineHandles'
of the blocks and delete them, so the block can get its new connection. But this only disconnects the lines which results in them piling up inside the library-block. Eventually this fails too, maybe because the unconnected signals auto-connect again or whatever.
Since the command
Simulink.BlockDiagram.arrangeSystem(gcb,FullLayout='true');
also does not work (it does nothing inside a library-block), it's becoming quite a mess.

请先登录,再进行评论。

采纳的回答

Fangjun Jiang
Fangjun Jiang 2022-11-30
编辑:Fangjun Jiang 2022-11-30
You forgot 'FollowLinks','On'
>> oldLines = find_system(gcb, 'FindAll', 'on', 'LookUnderMasks','all', 'type', 'line')
oldLines =
0×1 empty double column vector
>> oldLines = find_system(gcb, 'FindAll', 'on', 'FollowLinks','On','LookUnderMasks','all', 'type', 'line')
oldLines =
1.0e+03 *
5.6880
5.6870
5.6860
5.6850
5.6840
5.6830
5.6820
5.6810
  2 个评论
Manuel K
Manuel K 2022-11-30
Thanks, that was the issue. I already tried this to be honest, but I must have missed that there weren't any lines in the system at that time.
Could you also help with the other command? I'm sure I didn't miss the correct argument there.
Simulink.BlockDiagram.arrangeSystem(gcb,FullLayout='true');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Model Editing 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by