When working on complex molecular scenes in SAMSON, camera nodes can quickly accumulate. You might create a camera for each important orientation, set up different annotation views, or manage several visualization perspectives in parallel. Over time, finding and managing the right camera becomes less trivial, especially when you’re scripting or automating workflows.
Fortunately, the Node Specification Language (NSL) provides powerful ways to filter and work with camera nodes efficiently. In this post, we’ll walk through the camera attribute space in NSL and focus on how to use it to manage your cameras better—whether to identify them by name, filter by selection state, or script automated actions.
Understanding the Camera Attribute Space
Camera attributes are part of their own attribute space in NSL, with full name camera and short name ca. This scope uniquely targets camera nodes, allowing you to avoid ambiguity when other node types are also present in your scene.
This means that instead of filtering nodes generically, you can do things like:
|
1 |
ca.n "TopView" |
Which returns all camera nodes named TopView (or matching the wildcard, e.g., ca.n "Top*").
Key Attributes for Camera Nodes
The following inherited attributes are supported:
name(n): name of the cameraselected: whether the camera is currently selectedselectionFlag(sf): allows you to test for the selection flag state
Let’s break these down.
Filtering by Name
To select all camera nodes with a name containing “Side” you can use:
|
1 |
ca.n "*Side*" |
This is especially helpful if you follow consistent naming conventions (recommended!).
Checking Selection
You may want to know if a camera is selected. This is useful in scripting automation where a user’s current view (linked to a selected camera) might impact subsequent operations.
|
1 |
ca.selected |
Returns all selected camera nodes. Conversely, this:
|
1 |
not ca.selected |
Returns all unselected cameras.
Note: unlike other nodes, the selected attribute for camera nodes does not have a short name, so be sure to write it out fully.
Using Selection Flags
Selection flags offer more fine-grained control. For example, to get all camera nodes whose selection flag is not set:
|
1 |
ca.sf false |
This helps in many automation pipelines, such as exporting only non-flagged views or keeping memory use clean by removing unused cameras.
Practical Example: Scripting Camera Highlights
Suppose you want to perform an action only on views with names containing “L”, and only when they are selected. You could write:
|
1 |
ca.n "L*" and ca.selected |
This enables creation of very specific filters for automation, previews, or cleanup tasks.
Why This Matters
Refining your filtering strategy with NSL can save time and reduce errors, especially when handling large and evolving molecular models. Navigating more quickly through your camera collection makes annotation and documentation faster and ensures that you’re looking at the right perspective, at the right time.
To explore more about the camera attribute space in NSL, visit the full documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
