Hi,
As a dummy exemple, I created a new model, and its graphical icon is a green rectangle. I want it to become red when my Boolean variable is false. Is there any way to achieve such a thing? In the code hereunder I tried to add the condition
fillColor = if on then {0, 255, 0} else {255,0,0}
in the annotation, but this is not tolerated. I don’t find any example in Modelica text books.
model myBlock
Boolean on;
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Rectangle(visible = true, fillColor = if on then {0, 255, 0} else {255,0,0}, fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}})}), Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end myBlock;

