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');
Fangjun Jiang
Fangjun Jiang 2022년 11월 30일
It's not clear to me what the issue is. Please ask a separate question.

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

추가 답변 (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