When working on complex molecular scenes in SAMSON, it’s easy to accumulate multiple camera nodes—each representing different viewpoints, lighting setups, or visual documentation stages. But managing them efficiently can become challenging, especially when quickly switching perspectives or automating workflows. That’s where understanding camera attributes in the Node Specification Language (NSL) makes a significant difference.
Whether you’re scripting custom visual setups or simply navigating heavy projects, knowing how to select and filter camera nodes with NSL can save you both time and effort.
Why filter camera nodes?
Let’s say you have a dozen cameras in your document: some for publication snapshots, others for exploratory analysis, and a few outdated ones from earlier design stages. You might want to:
- Select only the cameras with a specific naming convention, like those starting with “Pub”
- Identify and remove unselected or inactive cameras
- Automate camera processing based on tags or status
The NSL provides straightforward syntax to target camera nodes using the ca (short for camera) attribute space. Here’s how.
Attribute breakdown
The camera attributes available through the NSL in SAMSON include:
- name (
n): Matches cameras by name using strings or wildcards - selected: Filters cameras based on selection status
- selectionFlag (
sf): A more technical flag used during selection operations
Each of these is inherited from the general node attributes in NSL, but restricted to entities of type “camera”.
Practical usage examples
Here are a few useful patterns that make camera node filtering practical and flexible:
1. Select all cameras whose name starts with “Pub”:
|
1 |
ca.n "Pub*" |
This can help you quickly isolate cameras intended for publication figures.
2. Find selected cameras:
|
1 |
ca.selected |
This filters only the cameras currently selected in your document.
3. Exclude selected cameras:
|
1 |
not ca.selected |
This is useful for batch operations (like deleting outdated setups) without affecting your active viewpoints.
4. Filter cameras with inactive selection flags:
|
1 |
ca.sf false |
This can be used for scripting conditions during custom procedural animations or simulations.
Combining filters
NSL is powerful because you can combine conditions. For instance, to select only unselected cameras with names beginning with “Tmp”:
|
1 |
not ca.selected and ca.n "Tmp*" |
This makes scripting and automation with visual elements highly efficient, especially in complex molecular systems where camera tracking is key to reproducibility.
Takeaway
Understanding and using camera attributes in NSL is a small but impactful enhancement in your workflow. It allows you to manage visual perspectives more precisely and automate time-consuming tasks.
To explore the complete camera attribute reference and examples, visit the official documentation: https://documentation.samson-connect.net/users/latest/nsl/camera/
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net
