Molecular modelers often manipulate large, complex systems composed of many structural and visual elements. Whether you’re highlighting specific atoms for analysis or preparing a figure for publication, controlling the visibility of these elements is essential. However, manually toggling visibility through a GUI can be tedious and error-prone—especially when repeated across multiple components or scenes.
This is where NSL (Node Specification Language) in SAMSON comes in handy. NSL allows you to write concise expressions to select and control nodes in a molecular model. In this post, we’re focusing on a particularly useful application of NSL for streamlining your work: toggling the visibility of molecular presentation nodes.
Why care about visibility?
In SAMSON, visual elements are represented by presentation nodes. These include renderings like ball-and-stick models, surfaces, and other visual representations of the molecular structure. Fine-tuning their visibility can help declutter your workspace, highlight key interactions, or simplify complex presentations.
NSL provides several presentation attributes to help you filter presentation nodes and control what is shown and what is hidden:
pr.v: Whether the node is visible (trueorfalse).pr.vf: Visibility flag (similar topr.v, but set via GUI).pr.h: Hidden attribute (complementary and inherited from general node attributes).
Practical examples
Let’s walk through a few common cases:
1. Show only visible presentation nodes
|
1 |
pr.v |
This selects all presentation nodes that are currently visible. Handy when you’re cleaning up a scene but want to preserve current focus points.
2. Hide all presentation nodes with a certain name
|
1 |
pr.n "Ligand" and pr.v |
This selects all visible presentation nodes named “Ligand”. You can then batch edit them to hide or disable rendering.
3. Toggle visibility programmatically
After selecting nodes using expressions like above, you can script or use SAMSON’s batch actions to toggle visibility or update specific flags. This reduces repetitive clicking and ensures consistency across related models or scenes.
What’s the difference between visible, visibilityFlag, and hidden?
This is a common question. Here’s the simplified breakdown:
pr.v(visible): Whether the node is displayed in the viewport.pr.vf(visibility flag): Reflects whether visibility is set via the GUI. Often used internally.pr.h(hidden): Another way of toggling whether nodes appear, useful in bulk operations and scripting.
Although they seem redundant, these attributes offer flexibility depending on whether you’re scripting, editing via GUI, or using selection queries. For most tasks, pr.v is the most intuitive and powerful.
A consistent language across your workflow
NSL expressions like pr.v, not pr.v, or pr.n "A*" and pr.v allow you to rapidly adjust the appearance of your model based on logical filters. If you’ve ever hunted for a specific node within a large model, imagine doing it with just a few keystrokes.
To learn more about how visibility and other presentation node attributes work in SAMSON, visit the full documentation page:
https://documentation.samson-connect.net/users/latest/nsl/presentation/
SAMSON and all SAMSON Extensions are free for non-commercial use. Get it at https://www.samson-connect.net.
