Easily Find Selected Folders in Your Molecular Simulations

When conducting molecular simulations or organizing structural data, it’s common to work with complex models that contain numerous folders and nodes. A recurring challenge for molecular modelers is identifying which elements in a hierarchical structure are selected—especially after interacting with visual elements, importing structures, or applying scripts.

This blog post explores a small but effective feature in SAMSON’s Node Specification Language (NSL): the selected attribute within the folder attribute space. While often overlooked, this attribute can be a powerful tool to streamline your selection workflows, clean up scenes, or apply operations to just the chosen folders.

Why Use the selected Attribute?

Imagine you’ve just imported a large molecular model comprising dozens of folders, each representing molecules, chains, or subsystems. You’ve then selected a few using the visual interface—maybe to measure distances, apply materials, or set visibility. Now, you want to programmatically operate only on the folders you selected. Instead of manually tagging or identifying them, you can rely on the simplicity of f.selected.

How It Works

The selected attribute checks if a folder is currently selected. The usage is straightforward:

  • f.selected matches selected folders.
  • not fo.selected matches folders that are not selected (with fo being any folder filter name).

Note that this is different from the selectionFlag attribute (sf), which can persist through user settings or scripting but may not always reflect the current interactive selection.

Practical Use Cases

Here are a few scenarios where selected comes in handy:

1. Applying Operations Only to Selected Folders

Need to change visibility or material settings only on actively selected folders?

→ Ensures you’re working with selected folders that are currently visible.

2. Filtering Selected Folders Based on Other Criteria

Want to isolate selected folders that have fewer than 1000 atoms?

→ Easily narrows down your focus area for editing or analysis.

3. Reverting Visibility on Selected Folders

If you accidentally hide a group of folders, and had manually selected them before changing the visibility, you can revert using:

→ Match just the folders you selected and set back their visibility flag.

Limitations and Notes

Unlike some other attributes, selected does not have a short name (like s). You must use the full name selected when querying. Also, this attribute is inherited from the general node attribute space but applies specifically to folders here.

Wrapping Up

The selected attribute is a simple but useful part of the SAMSON NSL that can help you focus your work on the subset of folders that matter. Whether you’re scripting, automating workflows, or just organizing project scenes, it saves time and reduces the chance of errors in large models.

To explore more folder-related attributes, check out the full documentation: https://documentation.samson-connect.net/users/latest/nsl/folder/

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

Comments are closed.