Quickly Show or Hide Labels in SAMSON Using NSL

In complex molecular scenes, quickly identifying and toggling label visibility can dramatically enhance your workflow in SAMSON. Whether you’re preparing a presentation, reviewing a molecular model, or debugging a simulation, being able to control which labels are shown (or hidden) helps you stay organized and focused.

This post introduces a practical solution for efficiently managing label visibility using NSL (Node Specification Language) in SAMSON. Specifically, we’ll look into how to filter and modify label nodes based on the visible and visibilityFlag label attributes.

Why control label visibility?

Molecular models can quickly become cluttered—especially when working with large systems. Labels are helpful to highlight key atoms, residues, or domains. But when they start to accumulate, controlling which ones are visible becomes essential. Rather than manually toggling each label on or off, NSL offers a more efficient way.

The label attribute space (la)

To filter label nodes specifically, you’ll be using the label attribute space in NSL denoted as la. The attribute visible, with the short name v, allows you to check or set whether a label is currently visible in the viewport.

Check for visible labels:

This will match all label nodes that are currently visible.

Check for invisible (hidden) labels:

This matches all label nodes that are currently hidden from view.

Example use cases:

  • Hide all labels: Select all visible labels using la.v and then toggle visibility off.
  • Show specific labels: Use name-based filtering like la.n "CA*" and not la.v to show only alpha-carbon labels that are currently hidden.
  • Toggle by visibility flag: Use la.vf for a persistent flag that can be toggled through UI or scripts.

How does visibilityFlag (vf) differ from visible (v)?

The visibilityFlag is a user-controlled flag indicating that the element should be shown, while the visible attribute reflects the actual rendered state. You can use both in conjunction to better manage labels programmatically.

Example:

This helps find labels intended to be visible but currently aren’t (perhaps due to parent node rules).

Summary

NSL filtering gives you fast, flexible control over scene elements. By mastering label visibility filters, you avoid visual clutter and gain better control over your molecular models—especially for communication and analysis tasks.

For more information and examples, visit the full documentation page on label attributes.

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

Comments are closed.