When working on complex molecular simulations, efficient rendering management can make a significant difference in understanding and presentation. For modelers using SAMSON, keeping track of visual styles applied to different molecular models—like surfaces, ribbons, or atomistic representations—becomes more practical with render presets. But how exactly can you filter and manipulate those render presets, especially when dealing with large scenes?
This is where the Node Specification Language (NSL) and its renderPreset attribute space come into play.
Why You Might Struggle With Render Presets
Imagine you’re preparing a publication-quality visualization involving different biomolecules, and you’ve applied several visual rendering styles: cartoons for proteins, surfaces for ligands, and wireframes for ions. Now you want to quickly enumerate all the surface representations and alter their transparency. Filtering and selecting exactly what you need could become tedious—unless you use a targeted NSL query.
Filtering Render Presets Like a Pro
The renderPreset (short name: rp) keyword in NSL lets you target only render preset nodes. Here’s a practical breakdown of what you can achieve:
1. Query By Name
If you’re organized and assign descriptive names to your render presets, you can retrieve them using:
|
1 |
rp.n "SurfaceStyleA" |
You can also use wildcard patterns:
|
1 |
rp.n "Surface*" |
This helps when you have themes—such as naming all surface presets with a common prefix.
2. Selected or Not?
Sometimes, you want actions to apply only to selected nodes. Use:
|
1 |
rp.selected |
This filters nodes that are both render presets and currently selected. Conversely, use:
|
1 |
not rp.selected |
to target unselected ones.
3. Using selectionFlag
The selectionFlag (short name sf) is useful when programming. For example:
|
1 |
rp.sf true |
This will find all render presets where the internal selection flag has been set to true. While similar to rp.selected, this might reflect a programmatic selection rather than a user-driven one.
Use Case: Recoloring All Surface Representations
Let’s say you’ve named all your surface representations with names starting in "Surface". You could batch update them using:
|
1 |
rp.n "Surface*" |
Then apply your new color settings or opacity changes to only those render preset nodes, without affecting ribbons or atom objects.
Conclusion
By leveraging the renderPreset attribute space in NSL, modelers can gain precise control over visual representation in their documents. This saves time and eliminates ambiguity when working across complex models or preparing curated visuals for communication.
Learn more in the official documentation: https://documentation.samson-connect.net/users/latest/nsl/renderPreset/
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
