You can extend the model using a Comment element with «ModelicaExtension» stereotype. The Modelica Extension comment can be owned by the element it is attached to or have a different owner. The Modelica Extension content is exported to the Modelica file together with the model. The Modelica code is generated depending on the owner of the Modelica Extension comment.


There are several cases of the model extension with Modelica Extension comments and how the content of the comments is exported:

  • When the comment is attached to a property which is owned by the Block. In the generated code, the Block is added as a model and the properties and content from the Modelica Extension comments are added in the same order as it was in the model. 
  • When the comment is attached to a Block. In the generated code, the content from the comment, attached to the Block is added first, and the content from the comments, attached to the Block's properties, is added afterwards.

  • When the comment is attached to an Instance. In this case, the Modelica code is generated the same way as for Block.

    You can attach the Modelica Extension comment to the nested instances. However, only first two levels of the nested instances are supported.