Working with label visibility in SAMSON using NSL

When working on complex molecular models in SAMSON, it’s easy for your screen to become cluttered—especially when multiple labels are displayed. Whether you’re tracking molecular IDs, distances, or other annotations, label visibility can quickly become overwhelming. What if there was a structured way to control which labels are visible at any time, directly using a concise language? That’s where the Node Specification Language (NSL) comes into play.

In this post, we’ll explore how you can manage label visibility efficiently using NSL. We’ll walk through how to use the la.v (visible) and la.h (hidden) attributes, and how this can help streamline your modeling process.

Why control label visibility?

Here are a few common scenarios where managing label visibility can save you time:

  • You have hundreds of label annotations but only want to focus on a selected few.
  • You want to hide less important labels for a presentation or publication screenshot.
  • You want to quickly isolate parts of a molecular system by toggling visibility flags based on conditions.

How NSL helps

SAMSON’s Node Specification Language allows you to query and control different nodes in your document with precision. For label nodes, NSL uses the label attribute space, or la in short. Two useful attributes for visibility control are:

  • la.v — indicates whether a label is visible
  • la.h — indicates whether a label is hidden

Some basic examples:

  • la.v — selects visible labels
  • not la.v — selects hidden labels
  • la.h — selects hidden labels (just like not la.v)

Yes, there is a redundancy here: la.h and not la.v are logically equivalent. However, depending on your modeling style, one may feel more intuitive and help build readable queries more quickly.

Visibility vs. VisibilityFlag

The documentation also references la.vf (visibility flag), which might be a point of confusion. Here’s the difference:

  • la.v: reflects actual visibility — whether a label is currently visible
  • la.vf: is a flag that instructs the rendering engine whether or not a label should be visible

This means you can have a label with la.vf = true but still not see it if its parent node isn’t visible. So for most cases, prefer la.v if you’re interested in what’s visible on-screen right now.

Combining Visibility with Other Attributes

You can combine visibility with other label attributes for powerful filtering. For example:

This selects all visible labels with names starting with “Distance”.

This selects hidden labels that are still flagged as selected — useful if you’re preparing to clean up hidden annotations.

Tips

  • Use not to invert selections for quick editing.
  • When scripting or batch processing molecular documents, NSL filters like la.v are helpful for automation.
  • Remember that visibility and selection flags are inherited from node attributes, making them consistent across node types.

For many molecular modelers, mastering label visibility through NSL can be a small adjustment that brings a large productivity boost. Visual clarity makes a big difference, especially when working with dense molecular environments.

To learn more about label attributes in NSL, visit the official documentation: https://documentation.samson-connect.net/users/latest/nsl/label/

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

Comments are closed.