I tried it with
ns_scoping = model.metadata.named_selection(ns_name) ns_scoping.id ns_scoping.ids
but this refers only to the nodes from the named selection.
The mechanical object ids are not in the results file. You will need to match the component name to the named selection solver name (NS.SolverName). This should be unique as you cannot have components with the same name in APDL.
Thanks Mike, that should work for me.