When working with complex molecular systems in SAMSON, an effective way to simplify visual analysis is to control the visibility of elements such as labels. Labels are useful for annotation, but too many of them can quickly clutter a 3D scene. If you’ve ever found yourself overwhelmed by overlapping text or want to generate cleaner images for presentations, it’s worth learning how to control label visibility using the NSL—the Node Specification Language in SAMSON.
SAMSON introduces a structured way to query and manipulate model components through NSL. For labels specifically, NSL allows you to specify attributes in the label attribute space (la), which includes visibility control using the visible and visibilityFlag attributes.
Why this matters
Visual clutter isn’t just an aesthetic problem—it can hinder your understanding of molecular interactions. For instance, labels can obscure key atoms or bonds, especially in large biomolecules. Being able to fine-tune which labels are visible makes your workspace more manageable and significantly improves clarity when sharing results.
Visibility vs. Visibility Flag
In SAMSON, there are two relevant NSL attributes:
visible(la.v): The actual visibility state of a label.visibilityFlag(la.vf): Controls whether the label is set to be visible or not by user intention.
Although they sound similar, these have distinct roles. Think of visibilityFlag as your personal switch (“I want to see this label”), while visible reflects whether the label is currently rendered, which may also depend on its parent visibility or scene settings.
Controlling Label Visibility with NSL
Here are a few practical NSL examples for controlling label visibility in molecular models:
- Find all visible labels:
la.v - Find all labels set to be invisible:
not la.vf - Find labels that are invisible but still flagged to be visible:
la.vf and not la.v - Hide all labels in one command: You can select all using
laand change the visibility through the Properties panel or scripting.
This level of precision is especially useful when preparing high-quality visuals for publications or educational material. Instead of manually clicking labels on and off, NSL lets you define visibility rules in a repeatable way.
Beyond Visibility: Additional Filtering
If you only want to hide some labels, not all, NSL makes it possible to be specific. For example:
la.n "*Hydrogen*": Targets labels with “Hydrogen” in their name.la.vf false: Filters labels intentionally hidden.
Combining filters gives even more control. A query like la.n "*Oxy*" and la.vf helps locate all oxygen-related labels that are intended to be visible.
You can find more details and syntactic examples in the original documentation page: 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.
