Search code examples
visibleanylogic

anylogic how to set port is visible on upper layer false


Can you explain the "is Visible on Upper Layer" property, please? It's on everything, yet I can't seem to find it programmatically.

I have a custom block, and I have parameters for the block that provide functionality options. When the user selects a certain configuration, I want to hide the port, text and graphics group associated with that option.

My preference is just to flip the flag "is Visible on Upper Layer" to false, however, I cannot find that option. For the text and the group, I can only set "isVisible" to true, and it doesn't have an option to set "is Visible on Upper Layer". For the port, there doesn't seem to be any code that impacts its visibility.

How can i control visibility on the upper layer for text, groups and ports in the icon of a custom block? Please help Thanks Brett


Solution

  • The property Visible on upper level is not accessible by code and can only be set via the editor during model development.

    As you already noted, the function to use here is setVisible(boolean), on the Agent level. The object will then be hidden both in the block itself, as well as in the upper level.

    If you dynamically want to hide some parts on the upper level, but always show them on the Agent level (inside your block), you will have to create two instances of them, one that is visible on upper level and one that is not. Only then you can hide one while showing the other using setVisible(boolean).

    For ports you are even more restricted, visibility can only be set via the editor during model development, and Visible on upper level can't be set at all.