Toggling Molecular Model Visibility with NSL Made Simple

When working with large molecular systems, visual clarity is critical. Whether you’re focusing on a region of interest or trying to declutter a scene for a publication figure, you often need to quickly toggle visibility of specific components. If you’re using SAMSON for molecular modeling, the Node Specification Language (NSL) provides a powerful, concise way to control node visibility without manual clicking.

This blog post introduces how to use NSL to manage property model node visibility using attributes like visible, hidden, and visibilityFlag. These options are particularly helpful for users who want to automate parts of their workflow or better customize their molecular scenes.

Understanding Visibility Attributes

In SAMSON’s NSL, you can filter or operate on nodes based on attributes. When it comes to visibility, NSL provides the following attributes in the pm (propertyModel) attribute space:

  • pm.v (visible): Indicates whether the node is currently visible.
  • pm.h (hidden): Indicates whether the node is hidden. This is essentially the inverse of visibility.
  • pm.vf (visibilityFlag): A lower-level flag used internally to decide whether a node should be drawn.

These provide direct access to the display status of your property model nodes.

Examples

Here are some example queries and what they do:

Selects all property model nodes that are currently visible.

Selects all property model nodes that are currently invisible (i.e., hidden).

Selects all property model nodes whose visibilityFlag is set to false.

And for hidden nodes:

Selects all nodes that are flagged as hidden.

These statements enable you to very quickly find and operate on invisible or hidden parts of your system, especially useful when dealing with assemblies, conformational variants, or nested systems.

Why It Matters

Many molecular modelers have experienced the issue of having too many overlapping elements. Trying to manually toggle visibility can be tedious and error-prone—especially with nested hierarchies. Using NSL expressions like not pm.v makes this precise and scriptable.

You might use these features to:

  • Quickly reveal only the nodes essential for your current analysis.
  • Create clean figures where unnecessary background elements are hidden.
  • Automate scene configuration using NSL-based scripts.

Using Visibility in Practice

You can try combining visibility filters with other selectors. For example, only show nodes that are visible and have a certain name:

This selects visible nodes whose name starts with “Ligand”. Or filter out everything visible that is not selected:

This logic is powerful for setting up visual scenes and saving valuable time when preparing presentations, publications, or video exports.

To learn more about property model attributes and how they’re used in NSL, visit the full documentation page at https://documentation.samson-connect.net/users/latest/nsl/propertyModel/.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.

Comments are closed.