When navigating complex molecular systems, researchers often need to focus on particular subsets of structures while temporarily ignoring others. For large models, manual selection and toggling visibility can become tedious. This is where SAMSON’s Node Specification Language (NSL) becomes a powerful ally.
In this post, we’ll focus on a common modeling challenge: how to selectively make parts of your structural model visible or hidden in an efficient way using NSL—without manually clicking through the model hierarchy.
Why Visibility Matters
Whether you’re building interactive scenes, preparing visuals for publication, or just trying to better understand your molecular system, fast and precise control over which nodes are shown or hidden can save time and reduce cognitive overload.
Understanding Visibility Attributes
SAMSON provides multiple attributes for handling visibility and selection of structural model nodes. Let’s explore these:
sm.h– Attribute for hidden. A node is hidden when this is set totrue.sm.v– Attribute for visible. Inverse ofsm.h. Setting this tofalsehides the node.sm.vf– The visibilityFlag. Indicates whether the visibility status is enabled.sm.selected– Targets the nodes that are currently selected in the Workspace.
Examples of NSL for Visibility Management
Here are a few scenarios and how NSL makes them easy to work with:
1. Hide All Structural Models
|
1 |
not sm.v |
Matches all structural model nodes where visibility is false.
2. Find and Show Hidden Molecules
|
1 |
sm.h |
This selects only the hidden structural models. You can then toggle visibility back on in bulk.
3. Select All Visible Nodes
|
1 |
sm.v |
Quickly targets structural models currently displayed in your scene.
4. Hide All Selected Nodes
|
1 |
sm.selected |
This targets the selected items. Combine this with visual toggling commands in SAMSON to hide or show them without deselecting manually.
5. Toggle Visibility for Nodes with Specific Tags
If your models are named or tagged systematically, you can use pattern matching:
|
1 |
sm.n "Ligand*" |
This selects all models that start with “Ligand”—easy to then hide or isolate.
Best Practices
- Use short names like
sm.vorsm.hfor fast queries. - Combine attributes: For example,
sm.v sm.n "A*"finds visible nodes with names beginning with “A”. - Use visibilityFlag (
sm.vf) for scripting scenarios where you need to track visibility toggles programmatically.
By integrating these simple yet powerful NSL expressions into your workflow, you can significantly speed up visualization tasks and stay focused on scientific discovery rather than interface micromanagement.
To learn more about visibility and other structural model attributes in NSL, visit the official SAMSON documentation.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
