If you’re working with complex molecular scenes in SAMSON, you already know how cluttered things can get. Whether you’re analyzing a large biomolecule or a protein-ligand complex, your screen might quickly become filled with visual models, surfaces, meshes, and more. Filtering out what’s important—visually—is a constant task. One common pain point: determining which visual models are actually visible, and controlling their visibility programmatically.
This is where the Node Specification Language (NSL) and, more specifically, the visual model attribute space, can help. NSL is a powerful tool in SAMSON for querying nodes, and it includes specific visual attributes that let you filter based on visibility, selection, and ownership of materials.
Why Visibility Matters
Molecular modelers often hide or show elements to focus on specific interactions or conformations. If you’re building a macro or working on a script to tidy up your scene—or export it—the ability to filter just the visible objects is essential. Here’s how you can do it using the vm.v filter in NSL.
Using the visible Attribute
The visible attribute in NSL corresponds to whether a visual model node is actually being rendered. To test if a model is visible, you simply write:
|
1 |
vm.v |
This will match all visual model nodes that are currently visible. If you want to find those that are hidden, negate it:
|
1 |
not vm.v |
This is incredibly useful if you’re running scripts or just want to highlight what’s on screen without manually reviewing hierarchy trees and eye icons.
More Fine-Grained: visibilityFlag
In some cases, a model might be invisible because its visibility flag is off, even though it would otherwise be visible. NSL lets you dive deeper with:
|
1 |
vm.vf |
This lets you query or change which models have been explicitly hidden. To find those with their visibility flag off:
|
1 |
vm.vf false |
This distinction is valuable when writing automation tools that need to preserve user intent—whether something is hidden temporarily or programmatically.
Combine Filters Meaningfully
Things get even more useful when you combine this with other attributes, for example:
|
1 |
vm.v and vm.sf |
This would find the visual models that are both visible and currently selected through the selection flag system. Perfect for exporting visuals or running analysis only on what’s visible and manually marked.
Or maybe you’d like to isolate visible models with a specific name prefix:
|
1 |
vm.v and vm.n "Lig*" |
Now you’ve limited visual filtering to visible models involved in ligand representation. Efficient, targeted, and avoids manual deselection and guesswork.
Recap
vm.vfinds all visible visual models.not vm.vshows which are hidden.vm.vfinspects whether a model’s visibility flag is enabled.- Combine filters with
and,orto refine your searches.
These small tricks can save a lot of time and lead to cleaner, more manageable workspaces. Learn more about all visual model attributes in the original documentation: Visual Model Attributes – SAMSON Documentation.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
