Main Content

Create and Edit Block Mask Icon

Create block mask icon using Graphical Icon Editor and Mask Drawing commands. You can toggle between the two modes from Mask Editor. This example shows how to draw a block icon with the following features using the Graphical Icon Editor.

  • The icon has the elements as shown in the following image.

  • Depending on the value of the block parameter FieldType, the permanent magnet or the spring is be visible on the icon.

  • The text that appears in the center of the icon takes the value of the block parameter CenterText defined in the Mask Editor.

block Icon

To create the block icon:

  1. Add a Subsystem block. To create mask on the block, right-click the block, then select Mask > Create Mask.

  2. In the Icon tab, click Drawing Commands and select Graphical.

  3. Draw the icon.

    • Select Rect from the drawing tools and draw a square.


      Enable the Grid and Snap to grid options to help shapes precisely align with each other.

    • Select the Line to draw a horizontal line touching the middle of the square.


      Enable the Rulers and Smart Guides options to align the element relative to other elements in the canvas.

    • Select the square and line elements and make a copy of them. Flip the copies horizontally.

      square and line elements flipped

    • Select Ellipse to draw a circle joining the two squares.

    • Add the text element DC in the center of the icon.

    • To draw the magnet, select Rect and draw a rectangle. Make a copy of the rectangle and place the rectangles next to each other. Fill the left rectangle.

      graphical icon editor icon drawing

    • You can hide the magnet element to position the spring element in the place of the magnet. To hide the magnet, select the magnet element, right-click, and select Hide. To draw the spring element, select Inductor and place it on the canvas. Flip the inductor element vertically. Adjust the edit points of the inductor element to form the loops of the spring.

    inductor and magnet


    You can rename the elements in the Element Browser for easy identification. You can also group or ungroup elements as per your requirements.

  4. Bind ports to the icon.

    • Enter the labels for the left and right ports using the text tool.

    • Bind the ports and port labels of the icon to align the port labels to the port in the canvas so that even when you resize the icon the ports and port labels remain together. To bind the port to the port labels, select the port label, go to Port Binding and select the port. You can also unbind the port.

      bind port

  5. Hide or unhide spring and magnet elements based on the block parameter condition.

    Configure the spring element to be visible when the FieldType parameter is Wound and the magnet element to be visible when the parameter is Permanent magnet

    • Right-click the magnet element and select Conditional Visibility > Add Condition.

    • Enter the condition FieldType=='Permanent magnet'.

      conditional visibility

    • Similarly, enter the condition FieldType=='Wound' for the spring element.

  6. Parameterize text.

    • Define the mask block parameter CenterText in the Mask Editor. The value of this block parameter appears in the center of the icon.

      graphical editor text parameterization

    • Select the text element and click Text Parameterization.

    • Enter the mask block parameter name CenterText in Parameter/Value.

      graphical editor text parameterization

      Parameter/Value returns the text or value during runtime. To see the evaluated value of a block parameter on the block icon, preview the icon on the Simulink® canvas.

  7. Preview the icon in Simulink.

    preview icon

  8. Click Save Mask to save the mask. Mask editor also allows you to save the icon separately as an SVG file.


    If you have changes in both Command Editor and Graphical Editor, you can save the changes in either one of the modes.

Related Topics