I am facing issue while adding a subsystem in my model using mscript when there is already a subsystem with different name
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
vignesh sainath
il 30 Gen 2024
Commentato: vignesh sainath
il 31 Gen 2024
Hi
I am facing the below error while adding a subsystem in my model using mscript when there is already a subsystem with different name
My Code to add a subsystem to model:
bh = Simulink.findBlocks('Script_Test');
Simulink.BlockDiagram.createSubsystem(bh,'Name','ss2');
Error Window details:
Error using createSubsystemImpl
Blocks and annotations must belong to the same parent to create a new subsystem
Error in slprivate
Error in Simulink.BlockDiagram.createSubsystem
Error in SW_Script (line 164)
Simulink.BlockDiagram.createSubsystem(bh,'Name','ss2'); - Show complete stack trace
Displaying stack trace:
Error using createSubsystemImpl
• In createSubsystemImpl
• In slprivate
• In Simulink.BlockDiagram.createSubsystem
• In SW_Script (line 164)while adding a subsystem in my model using mscript when there is already a subsystem with different name
0 Commenti
Risposta accettata
Fangjun Jiang
il 30 Gen 2024
Modificato: Fangjun Jiang
il 30 Gen 2024
The way you run bh = Simulink.findBlocks('Script_Test'), the returned blocks are not in the same level, thus the error.
Most likely, you mean to do this:
f = Simulink.FindOptions('SearchDepth',1)
bh = Simulink.findBlocks('Script_Test',f);
Simulink.BlockDiagram.createSubsystem(bh,'Name','ss2');
3 Commenti
Fangjun Jiang
il 31 Gen 2024
Read the help doc of Simulink.findBlocks and Simulink.BlockDiagram.createSubsystem, you should be able to figure it out.
Likely, if you change one line to bh = Simulink.findBlocks('Script_Test\ExistingSysName',f), it will copy all the blocks inside "ExistingSysName" block.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Subsystems in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!