Find the mesh you need: a practical guide to SAMSON’s mesh queries

When a molecular scene contains many objects, a simple task—like checking which meshes are visible or finding one by name—can turn into a search through a crowded structure. SAMSON’s Node Specification Language (NSL) lets you describe the mesh nodes you want to match using concise expressions. The key is to use the mesh attribute space, me, and choose an attribute that answers the question you are actually asking.

Start by narrowing the search to meshes

The mesh attribute space matches only mesh nodes. That makes me a useful starting point when your query is specifically about meshes rather than every kind of node in the scene. For example, me.n "A" uses the mesh name attribute, while me.v uses the visibility attribute.

Mesh attributes inherit several attributes from the general node attribute space. These include name, hidden, visible, and material-related attributes. You can therefore use the mesh prefix with those inherited attributes instead of needing a separate mesh-specific version.

Search by name without losing the mesh context

If you know a mesh’s name, use me.n followed by a quoted string. The reference gives me.n "A" as an example. It also shows me.n "L*", which is a useful pattern to try when working with names that share a prefix. Keeping the me prefix makes the intended scope clear: the query is about mesh nodes.

Check visibility deliberately

Visibility questions are easy to phrase as positive or negative checks. Use me.v to match meshes whose visible attribute is true, and not me.v to match those for which it is false. The longer attribute name, visible, is also available as v.

The mesh reference also lists hidden (short name h) and visibilityFlag (short name vf). For example, me.h and me.vf false are valid examples. These are separately named attributes in the reference, so when building a query, use the one that corresponds to the state you intend to inspect rather than treating the names as interchangeable.

Keep selection and flags distinct

For selection-related checks, the page lists both selected and selectionFlag. You can write me.selected or not me.selected to query selection state. One detail worth remembering: in the mesh attribute space, selected does not have the short name s. The selectionFlag attribute does have the short name sf, with examples such as me.sf and me.sf false.

Because these attributes are listed separately, it is safer to query the particular one you need than to assume that selected and selectionFlag mean the same thing in every situation. A clear expression is easier to review later, especially when you are troubleshooting why a mesh appears in a result or why it does not.

A quick query checklist

  • Use me when you want to match mesh nodes specifically.
  • Use me.n for names, and put the name string in quotes.
  • Use me.v or not me.v for visible-state checks.
  • Use me.selected for selection state; remember it has no short name in this attribute space.
  • Choose the explicit flag attribute—me.vf or me.sf—when that is the state you mean to query.

These small distinctions can make a mesh search easier to understand and maintain. For the full attribute list and additional examples, see the SAMSON mesh attributes reference.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.

Comments are closed.