When working on complex molecular models, a common frustration is navigating through multiple visual states and trying to consistently control how parts of your model are rendered. If you’ve ever wished you could quickly select or filter different rendering configurations in SAMSON without hunting through the GUI, you’re not alone.
The Node Specification Language (NSL) in SAMSON provides a structured, simple way to query and manipulate elements in your molecular scene. In this post, we’ll explore how you can use renderPreset attributes to efficiently manage rendering presets in your workspace.
What’s a Render Preset?
A render preset in SAMSON defines how molecular structures are visualized—settings like material, shading, and lighting conditions. These nodes control appearance, and they’re critical when your goal is to make publication-ready images or simply highlight specific features of a molecule.
Filtering and Selecting Render Presets with NSL
The renderPreset attribute space (short name: rp) is a clean way to work with these nodes programmatically. Let’s look at key attributes and how you might use them.
1. Name your presets for quick selection
Use the name attribute (rp.n) to find presets by name or pattern. This is invaluable when you’re dealing with many presets and need to locate or apply a specific one:
|
1 |
rp.n "GlossyHydrophobics" |
You can even use wildcards:
|
1 |
rp.n "L*" |
This selects all render presets with names starting with “L” (e.g., “LigandHighlight”).
2. Detect which presets are currently active
The selected attribute tells you whether a given render preset node is selected in the document. For example:
|
1 |
rp.selected |
This returns all selected render presets. Combine this with not to see which are inactive:
|
1 |
not rp.selected |
3. Use selectionFlag for more nuanced queries
This attribute (rp.sf) relates to a lower-level selection mechanism that can be manipulated internally or via scripts. It’s especially useful if you’re building tools or automating visual workflows. To select presets with the selection flag off:
|
1 |
rp.sf false |
Why This Matters
When managing complex molecular visualizations, you may deal with multiple layers of rendering logic—surface highlighting, transparent overlays, environmental shading, and so on. Typing quick NSL queries gives you control and consistency without navigating long trees of nodes manually.
Importantly, these render presets can be changed, duplicated, and reused across sessions. So being able to name and search them effectively ensures reproducibility, collaboration, and even automation when you’re running large-scale simulations across multiple structures.
Learn More
You can learn more about render preset attributes in the official documentation: https://documentation.samson-connect.net/users/latest/nsl/renderPreset/
SAMSON and all SAMSON Extensions are free for non-commercial use. Learn more and download at https://www.samson-connect.net.
