When working on large, intricate molecular systems, things can get visually overwhelming fast. Whether you’re scripting, selecting, or simply trying to organize your workspace, being able to efficiently control what appears in your scene can speed up your workflow and reduce errors.
This post explores how to control the visibility of visual models using the visualModel attribute space in SAMSON’s Node Specification Language (NSL). If you’ve ever found yourself toggling elements on and off manually just to get a clearer view of your molecule—or worse, accidentally hiding something permanently—this may save you time and frustration.
Understanding Visual Model Visibility
Each visual model in SAMSON (such as ball-and-stick models, surfaces, etc.) can have visibility-related attributes assigned to it through NSL. These attributes are grouped under the visualModel (short name: vm) namespace. For visibility control, there are three key attributes to know about:
visible(v): Whether the model is currently visible or hidden in the scene.visibilityFlag(vf): A flag used to manage visibility state changes at a finer level.hidden(h): Indicates whether the node is flagged as hidden. It’s the logical opposite ofvisiblein some cases.
To query or modify visibility states in a Node Specification, use syntax like:
|
1 2 3 4 |
vm.v // all visual models that are visible not vm.v // all visual models that are not visible vm.vf // models with visibility flag on vm.h // models flagged as hidden |
Use Case: Quickly Hide or Show Specific Visual Models
Say you’re working with multiple representations of a protein—surface, cartoon, and atomistic—and want to view only one at a time. Instead of digging into the GUI, you could use a Node Specification like:
|
1 |
vm.n "*surface*" and not vm.v |
This will select all visual models whose name contains “surface” and are currently hidden. You can then easily toggle their visibility through scripting or the Inspector panel.
Need to hide everything else? Try:
|
1 |
not (vm.n "*surface*") and vm.v |
This targets all visible visual models except the surface, meaning you can now hide them in one go.
Scripting Tip: Batch Visibility Management
Combining NSL with scripting can give you precise and repeatable control. For instance, to turn off all models that do not own their material (i.e., shared styles):
|
1 |
vm.om false and vm.v |
That selects non-owner visual models that are currently visible—you can now hide the selection, preserving your working view.
These small efficiencies add up, especially when you’re preparing scenes for publication or analysis. Avoiding accidental selections, misalignments, or just the clutter of too many overlapping representations can improve both confidence and clarity in your modeling tasks.
To learn more about all available attributes for visual models in NSL, visit the documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at www.samson-connect.net.
