Quickly Selecting and Filtering Cameras in SAMSON with NSL

Molecular modelers often work with complex scenes that include multiple camera nodes—each representing a different point of view on the system. Whether you’re preparing publication-quality figures, recording an animation, or just switching between perspectives during a simulation, managing these camera nodes efficiently is crucial.

SAMSON’s Node Specification Language (NSL) provides a structured and powerful way to filter camera nodes based on attributes. In this post, we’ll explore how to use the camera attribute space for filtering and selecting cameras, focusing on three key properties: name, selected, and selectionFlag.

Getting Started with the Camera Attribute Space

Camera attributes in NSL live in the camera attribute space, abbreviated as ca. This means that any query that starts with ca. will match only camera nodes in your document. These camera nodes inherit several useful attributes from the general node attribute space.

1. Filtering Cameras by Name

If you’ve named your cameras descriptively (e.g., “Top View”, “Front View”, etc.), you can use these names to select cameras quickly:

This will match any camera whose name is exactly “Top View”.

Want a wildcard match instead? Use an asterisk:

This targets all camera nodes whose names start with “View”.

2. Selecting Cameras Currently Selected

Sometimes you want to find out which camera nodes are currently selected. This is helpful when scripting workflows or applying modifications only to active cameras.

To find cameras that are not selected:

3. Using selectionFlag to Group Cameras

The selectionFlag (abbreviated sf) is often used to track which elements are part of a defined selection or group. Here’s how to find cameras that were previously saved into such a group:

…or to find those which are not part of it:

Why Use NSL for Cameras?

Managing multiple cameras manually can become tedious, especially in large molecular assemblies. NSL provides a clean way to automate and refine selections, saving time and reducing the chance of mistakes.

Consider combining camera queries with node-based operations. For instance, performing batch updates to all cameras whose name includes “Export” or toggling visibility flags programmatically with scripts.

This level of control becomes particularly useful when creating videos that require dynamic changes in camera viewpoints or when preparing documentation that includes consistent camera perspectives across different stages of a simulation.

Want to Learn All Attributes?

To fully make use of NSL with camera nodes, check out the complete list of attributes on the official documentation page. It includes detailed behavior for name, selected, and selectionFlag, as well as their connection to the broader node attribute space.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.

Comments are closed.