The Modelica platform in detail > Creating Modelica models
Assembling a Modelica model graphically
In the previous subsections, we showed the creation of a model using the Modelica source code directly in the Text view. The Modelica Editor also allows you to assemble models graphically in its Diagram view via drag-and-drop operations similar to Simcenter Amesim’s Sketch mode. To demonstrate this approach, use the New Class dialog to create another model within your MyLibrary package as shown below.
Figure 14: Using the new class dialog to create another model within MyLibrary
We will begin by manually declaring the same parameters used in the other versions of this integrator model. With this model selected, use the Text view to add the following lines of code.
Figure 15: Using the Text view to declare the parameters v and x0
Switch to the Diagram view of this model to create the model using some existing components from the Modelica Standard Library (MSL). First, find the model Modelica.Blocks.Continuous.Integrator block in the library tree, then drag-and-drop it onto the Diagram view of your GraphicalIntegrator model as shown in the figure below.
Figure 16: Dragging-and-dropping an Integrator into the GraphicalIntegrator model
Next, locate the Modelica.Blocks.Sources.Constant class and drag an instance of it onto the same GraphicalIntegrator diagram as show in the figure below.
Figure 17: Dragging-and-dropping a Constant into the GraphicalIntegrator model
In object-oriented terms, the components we have added on the sketch are not “copies” of the classes taken from the MSL, but “instances” of them, having their own parameter values. To set the parameter values of an instance, select it in the Diagram view. The Diagram view contains a special “Parameters” contextual view at the bottom of the screen. You can also show it in other views, if desired, but the default layout shows it only in Diagram view. First, select the constant block and set the value of the parameter k to the value v (the parameter we declared earlier) as shown in the figure below. Second, select the integrator block and set its y_start parameter value to the parameter x0 that we declared earlier as shown in the figure Figure 19.
Figure 18: Setting the parameter “k” for the constant_1 component
Figure 19: Setting the parameter “y_start” for the integrator component
Of course, you can also connect components together in the Diagram view. When your mouse is hovering over the output connector of the Constant block, it will switch from a hand-shaped “select” cursor to a line-shaped “connect” cursor (the figure below on the left). Sometimes it is helpful to zoom in via the buttons (or Ctrl+scroll wheel) in order to more accurately position the cursor. Click on the Constant’s output to begin a new connection. You can then left-click to add elbows in the connection whenever desired, or right-click to undo elbows. Once the mouse is hovering near another connector (the input of the Integrator block in this case), it will show a green box (as shown in the figure below on the right). Click on that connector to complete the connection.
Figure 20: Left: starting a new connection. Right: completing the connection
At this point, you have created an integrator model by graphically assembling existing components from the Modelica Standard Library. The text view will show the instances of the components you added as well as the connection equation (see figure below). The graphical information about where these components sit on the sketch is stored in Modelica annotations. To make the code more readable, the Modelica Editor hides these annotations by default. You can hover over an annotation to preview what it contains or click on … icons or the + / - signs beside the number line to expand / collapse them.
Figure 21: Modelica source code for the graphically assembled integrator model
Your Modelica library now contains a graphically assembled model that can be compiled and simulated, as will be described in the Translating Modelica models section.
Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Modelica_Platform/xid1196786 · retrieved 2026-07-17