A Cleaner Way to Find Meshes in SAMSON

When a molecular scene contains many kinds of nodes, a search can become frustrating if it returns objects you did not mean to inspect. Meshes have their own Node Specification Language (NSL) attribute space, which gives you a direct way to narrow a query to mesh nodes and then refine it using attributes such as name, visibility, and selection state.

Start with the mesh attribute space

The mesh attribute space is written mesh, with the short name me. It matches mesh nodes only. That makes it a useful starting point when your task concerns meshes and you want to avoid matching other node types.

For example, these expressions query mesh attributes:

  • me.n "A" — use the mesh name attribute with the quoted value "A".
  • me.n "L*" — use the documented name pattern example.
  • me.v — query the visible attribute.
  • not me.v — query the opposite condition for that attribute.

Starting with one condition at a time can make troubleshooting easier: if a query does not identify the meshes you expect, check the attribute and value before adding more criteria.

Know which attributes are available

The mesh attribute space includes attributes inherited from the general node attribute space. In other words, these are available when working with meshes, even though they are not exclusive to meshes.

  • hasMaterial (hm) and ownsMaterial (om) accept true or false. Example: me.hm.
  • hidden (h) and visible (v) accept true or false. Examples: me.h and not me.v.
  • name (n) uses strings in quotes. Examples: me.n "A" and me.n "L*".
  • selected accepts true or false, and is written in full: me.selected or not me.selected.
  • selectionFlag (sf) and visibilityFlag (vf) accept true or false. Examples: me.sf false and me.vf false.

A small but useful detail: selected has no short name in the mesh attribute space. Use me.selected, rather than assuming that a shorter form is available. By contrast, selectionFlag has the short name sf.

Keep similar-looking attributes distinct

The reference lists hidden, visible, and visibilityFlag as separate attributes. It also lists selected and selectionFlag separately. Their names may sound related, but the attribute list alone does not say they are interchangeable. When a query depends on one of these properties, use the specific attribute you intend to test instead of substituting a similarly named one.

The same care applies to hasMaterial and ownsMaterial: both are available, but they are separate attributes. If material-related filtering matters to your task, choose the attribute that matches your question and consult its definition rather than treating the two names as synonyms.

A practical filtering routine

  1. Use the mesh space, me, to keep the query focused on meshes.
  2. Choose the attribute that reflects your task: name, visibility, selection, or material-related state.
  3. Use the documented short name where available, or the full attribute name when no short name is listed.
  4. For a negative condition, use the documented not form, such as not me.h.
  5. If the result is unexpected, simplify the expression and check each condition on its own.

This approach helps prevent a common source of wasted time: debugging a complicated filter before confirming that its basic attribute and value are right. For the complete attribute reference and additional context, see the SAMSON mesh attributes documentation.

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

Comments are closed.