Quickly Focus on the Right View: Filtering Cameras in SAMSON with NSL

When working with complex molecular systems in SAMSON, managing multiple cameras—each representing a different molecular view or visualization setup—can easily become overwhelming. Especially in large projects or collaborative environments, a user might find themselves digging through long lists of viewpoint configurations to locate the one they need. Filtering these camera nodes manually is time-consuming and error-prone, particularly when dealing with dozens or even hundreds of cameras named and organized in inconsistent ways.

This is where the Node Specification Language (NSL) comes in handy. NSL lets you quickly and expressively locate, select, and manipulate elements in your design, including camera nodes. This blog post introduces some efficient techniques for filtering and identifying camera nodes using NSL’s camera attribute space (ca for short).

Why filter cameras?

Let’s say you have a scene with multiple views: a top-down view, several zoomed-in snapshots of active sites, and maybe a few perspectives set up for a publication. You only want to work with those related to a specific task (e.g., ligand docking). Instead of scrolling and clicking around in the Document View, use a simple NSL query:

This returns all cameras whose name starts with “Docking-“. Handy, right?

Available Attributes

The camera attribute space offers a few key properties to filter and work with:

  • name (n): Filter cameras based on their name (using string matching like wildcards).
  • selected: Test whether a camera is currently selected. There’s no short name for this one.
  • selectionFlag (sf): Indicates whether the selection flag is set for the node (useful for scripts and workflows).

Here are some example use cases:

  • ca.selected: Find all selected camera nodes.
  • not ca.sf: Find all camera nodes that do not have the selection flag set.
  • ca.n "View-*" and ca.selected: Narrow down cameras whose names start with “View-” and that are currently selected.

Putting it in practice

Let’s say you are setting up a script that iterates through only specific cameras for rendering. Preparing queries like these in NSL simplifies the setup and reduces manual errors. For example, to programmatically apply an operation to all non-selected cameras, you can start with:

Then use that result set in your automation or scripting logic (e.g., for batch rendering or metadata updates).

Conclusion

Effectively managing your molecular views in SAMSON can dramatically speed up your workflow. NSL’s camera attribute space lets you filter and locate cameras based on meaningful conditions using short, readable expressions. By mastering just a few camera-related attributes—name, selected, and selectionFlag—you’ll spend less time navigating and more time designing.

To explore more about filtering and camera attributes in NSL, see the full documentation page here: 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.

Comments are closed.