Modeling operations often perturb a model's layout. Layout readjustment is usually needed, and represents a tedious activity if performed manually. Although achieving a proper layout of a Simulink model is deemed very important, there does not exist a comprehensive commercial automatic layout tool for Simulink models. The Auto Layout Tool reuses a graph drawing algorithm as implemented in the open source tool Graphviz to achieve a proper layout of Simulink models. The tool resizes models' blocks based on number of inputs and outputs, and organizes the signal lines such that the number of crossings is minimized. The tool also supports a number of minor yet very practical transformations: transforming a From/Goto connection to a signal line connection (and back), as well as flattening of a model’s hierarchy.
For installation instructions and instructions on how to use the tool, see doc/AutoLayout/AutoLayout_UserGuide.pdf.
For more about the capabilities of the tool and how it can be used in model-based development with Simulink, see the two papers:
Vera Pantelic, Steven Postma, Mark Lawford, Alexandre Korobkine, Bennett Mackenzie, Jeff Ong, Marc Bender, "A Toolset for Simulink: Improving Software Engineering Practices in Development with Simulink," Proceedings of 3rd International Conference on Model-Driven Engineering and Software Development (MODELSWARD 2015), SCITEPRESS, 2015, 50-61. (Best Paper Award)
Vera Pantelic, Steven Postma, Mark Lawford, Monika Jaskolka, Bennett Mackenzie, Alexandre Korobkine, Marc Bender, Jeff Ong, Gordon Marks, Alan Wassyng, “Software engineering practices and Simulink: bridging the gap,” International Journal on Software Tools for Technology Transfer (STTT), 2017, 1-23.
@Honigmelone: Thank you for the feedback. We are interested in looking at your model, if you can share it with us, so that we can work on addressing this issue. You can e-mail us at firstname.lastname@example.org
Good idea, unfortunately it does not really perform well with flipped blocks for me (such as in feedback loops).
@Ganesh Hegade: The newest version of the tool (1.4) should address the issue you are encountering. Thanks again for your feedback.
@Ganesh Hegade: We will look into ways of fixing this issue. Thank you for bringing it to our attention!
This is a pretty nice tool to perform AutoLayout of Simulink system. Thanks a lot for providing this tool.
I am using this tool from sometime and i found below bug.
In my work I created a Matlab GUI and added an option to create Simulink diagram from GUI. After the creation of Diagram i was trying to call AutoLayout to rearrange the blocks. But while rearranging blocks, Auto Layout Tool is closing the GUI itself and then throwing the error saying the model is not found.
Investigation / Possible reason :
I tried to debug the error and found that the error is inside the functions getTextHeight and getTextSize. Here you are using command "uicontrol", and then closing the parent of the figure using "close(get(x, 'parent'));". But if you have a Matlab GUI open, then by default Matlab GUI will become parent(as GUI is a figure) and the close command closes the GUI and all other things. Hence the error.
As a work around I am creating a new figure before assigning the "uicontrol" and making that as parent. This workaround looks as below:
function height = getTextHeight(string, block)
newFig = figure;
x=uicontrol('Style', 'text', 'FontName', fontName, 'FontSize', fontSize);
set(x, 'String', string);
Same solution for getTextSize also.
Can you please check is there any better workaround or solution can be added for this in upcoming releases.
@Torsten Knodt: Thank you for checking out our tool. We are interested in looking at your model, if you are able to share it with us. You can e-mail us at email@example.com
nice to see the submission of such a tool here.
I have tried your toolbox on a relatively small SimPowerSystems model with a relatively "chaotic" result. For the case you are interested, I can provide you the model or pre-post screenshot and dot file to e.g. an email address of your choice.
@Rami: Thanks for bringing this to our attention. This error seems fairly non-specific, so we are going to ask a couple questions to see if we can understand better what occurred.
1) What's size of the model in terms of number of blocks?
2) What are your naming conventions on blocks? Anything with spaces and/or newlines? We've had issues with that before.
3) Does the tool attempt to move any blocks or change the model in any way before the error occurs?
4) In the directory where you saved the Auto Layout Tool, is there a .dot file that was generated from the model?
This should give us a better idea of when the error was produced.
Thanks, Bennett and Gordon
I get the following error when trying to apply on a complicated system with subsystems and feedback loops.
"Error using dotfile_creator (line 149)
Invalid Simulink object handle
Error in initLayout (line 40)
Error in AutoLayout (line 32)
Error in AutoLayoutGUI>pushbutton1_Callback (line 85)
Error in gui_mainfcn (line 96)
Error in AutoLayoutGUI (line 42)
Error while evaluating uicontrol Callback"
I tried out the examples and they work. Please responed and help me out.
Great idea! I will test and give you feedback. Please continue supporting it
@William Knox: Thank you for the feedback! From what we can tell based on your situation, you are working on a very large scale system. Presumably with the scale at which you're working at, when the Auto Layout Tool tried to space things out for legibility's sake it exceeded the hard limits of MATLAB's position coordinates, and threw an error when it tried to move a block past said point. This is something we can definitely consider, and we're glad it's been brought to our attention.
To best address this concern, would it be possible for you to give us the .dot file produced when the error was thrown? When the program completes its execution successfully, normally it gets rid of the file as part of cleanup. However, since yours cut out before it could finish, we would imagine the file was still there, in the directory where you saved the Auto Layout Tool toolbox (most likely, this is under MATLAB/Toolboxes/Auto Layout Tool). Thanks, Bennett and Gordon
I successfully installed and tested example model in Matlab 2014a (via System Generator 2014.3).
Tried to run on a subsystem with
-522 'Inport' blocks,
-522 Xilinx SYSGEN 'Up Sample' blocks,
-an 'm-code' block with 522 input ports and 52 output ports, lastly
- the 'm-code' block has terminated outputs i.e. all output ports are connected to 'Terminator' blocks (for testing).
The position of the 'm-code' block is [870 165 1165 21165].
An excerpt of the errors produced is provided below (between ---> and <---):
Error: Edge length 286957.000000 larger than maximum 65535 allowed.
Check for overwide node(s).
many more of the type of errors shown above ... and below --->
Error: Edge length 175524.000000 larger than maximum 65535 allowed.
Check for overwide node(s).
Error using TplainParser/go_to_the_right_spot (line 105)
Input bounds are out of range
Error in TplainParser/plain_wrappers (line 45)
go_to_the_right_spot(object, object.RootSystemName,mapObj, graphinfo);
Error in AutoLayout (line 46)
Error in AutoLayoutGUI>pushbutton2_Callback (line 95)
Error in gui_mainfcn (line 95)
Error in AutoLayoutGUI (line 42)
Error in @(hObject,eventdata)AutoLayoutGUI('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I appreciate that this model/subsystem may not be a typical model/subsystem and that the 'Auto Layout Tool' was probably not designed for such models/subsystems.
This submission is not so much a request for help but more a feedback (for a possible bug fix).
Thank you for your time.
Updated the "Other Requirements" text.
The tool uses Graphviz, which is a set of tools for drawing graphs (see the user guide for instructions on how to install/setup Graphviz). The Auto Layout Tool has been tested with R2011b, R2015a, R2015b, R2016a, and R2017a.
Updating formatting of description.
- Corrected the tool name
- Fixed issue with the Context Menu
- Addressed issue raised by Ganesh Hegade regarding closing of GUI windows.
Updating cover image. Removed a "Required Product" from the list.
Added transformations from a From/Goto connection to a signal line connection (and back), as well as a transformation that replaces a virtual subsystem with its content (subsystem flattening).
Added the function getAllLinePoints.m that was missing in the previous release to further improve upon the layout produced by the tool.
– Improved line routing, sizing of blocks, and spacing between blocks,
Now working on Linux and Mac OS X.
Added the cover figure for the tool.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.