unable to programmatically find lines inside a custom library-block

4 visualizzazioni (ultimi 30 giorni)
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 Commento
Manuel K
Manuel K il 29 Nov 2022
Modificato: Manuel K il 30 Nov 2022
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.

Accedi per commentare.

Risposta accettata

Fangjun Jiang
Fangjun Jiang il 30 Nov 2022
Modificato: Fangjun Jiang il 30 Nov 2022
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 Commenti
Manuel K
Manuel K il 30 Nov 2022
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 il 30 Nov 2022
It's not clear to me what the issue is. Please ask a separate question.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by