AmesimKnowledge

The Modelica Editor > The Graphical User Interface

The Text Editor

Text Editor

The New Class dialog box

The Text Editor displays the Modelica code of any Modelica class you open, or is used to write new Modelica code directly. To start writing Modelica code, click the New button .

The New class New class dialog box opens:

Figure 14: New class dialog box

Here, you can select the class type, enter a name and description, and click to select the package in which to insert your new class.

You can now type Modelica code directly in the Text Editor:

Writing Modelica Code

Figure 15: Writing Modelica code

As you type, the Modelica Editor signals syntax errors in the Message Window and underlines them in red in the Text Editor:

Auto completion

Auto completion You can use the auto completion feature to help you when writing Modelica code. When you type a package name in the Text Editor, you can press Ctrl+Space to bring up a list of the reference packages that are currently loaded in the Library tree.

Figure 16: Using Auto completion

You can press Enter to select the highlighted term, use the Tab key, or use the mouse or arrow keys to select a term from the list.

You can display the list of children in a package, model or class by entering a period (.) when using auto completion:

Figure 17: Displaying children

Drag and drop

You can drag and drop packages to the Text Editor:

Figure 18: Dragging and dropping a package

Code folding

code folding

Through the use of annotations, you can encode information about how a component looks on the screen. You can also use annotations to give additional information to help the compiler process equations, specify GUI behavior, or store information such as documentation or versioning. Modelica models can be stored hierarchically; a single .mo file can contain dozens of individual Modelica models.

Because users may not always want to view the supplemental information within the annotations, code folding makes it possible to collapse entire sections of code to improve legibility. Users can then expand such sections as required.

Depending on the root class contained in a class that you open in the Text Editor (package, model...) different folding settings are applied. If the class you open is a package (in other words, the first block of the class is a package), everything it contains is folded (classes and annotations). If the class is not a package (in other words, the first block of the class is a model or a function for example) then only the annotations are folded, and class contents remain visible.

Figure 19: Folding blocks collapsed

You can expand a folding block as follows:

  • Click the symbol to the left of a block: Figure 20: Folding block expansion symbol

    Once a folding block has been expanded, the symbol changes to a symbol, which you can click to collapse a folding block: Figure 21: Collapsing a folding block

  • Click the Folding icon: Figure 22: Folding icon

  • Right-click and select an option from the Code folding contextual menu: Figure 23: Code folding contextual menu

    Clicking on Expand All unfolds every folding block in the document (annotations, packages, models...).
    
    
    Clicking on Collapse All folds every folding block in the document (annotations, packages, models...).
    If any folding blocks are nested in the block in question, those child blocks are also folded.
    
    
    Clicking on Expand All Annotations expands only the annotations present in the document.
    
    
    Clicking on Expand All Classes expands only the classes present in the document.
    
    
    Clicking on Collapse All Annotations folds all the annotations in the document but leaves the classes unchanged.
    
    
    Clicking on Collapse All Classes folds all the classes in the document but leaves the annotations unchanged.
    

Additionally, hovering the mouse cursor over a folding icon provides a tooltip preview of the hidden block. You may click within the tooltip preview to expand the folding block.

Figure 24: Folding block tooltip

Access to model definitions

You can access model definitions by hovering your mouse cursor over a class name and pressing the Ctrl key. A hyperlink will be activated, clicking it will open the corresponding class in the same tab.

Figure 25: Activating the hyperlink

Alternatively, the link is available through a right-click and selecting Go to Definition:

Figure 26: Go to definition

The definition opens in the same tab. You can use the navigation arrow to return to the previous view in the Text Editor.

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Modelica_Editor/The_Text_Editor · retrieved 2026-07-17