Make mesh unselectable

Hello everyone! Sorry for disturbing. I have a question and maybe some of you will be able to help me.
I would like to add Attribute where animator will be able to make mesh “unselectable/selectable”.
I can see what I have 2 options, but I am not happy with them.

  1. Under Attribute Editor → Display, I can connect my “unselectable mesh attr” to the “Template”. But it makes mesh “transparent”
  2. Under Attribute Editor → Drawing Overrides enable Overrides and put it to Reference. But it getting “broke” if artist will select mesh and will add in to the “Display Layer”.
    I am wondering maybe we do have 3 option? Or only way to do it: create “dummy grp” on top and connect that group in to " Drawing Overrides → Enable Overrides → Reference"?

Thank you in advance

Transforms and shapes have separate drawing overrides.

So if you connect your mesh shape’s override to your selectable attribute, even if the animators put the transform or geo group under a Display Layer, it will still work.

Adding a dummy group on top won’t work, because the override will honor the lowest part of the hierarchy. So even if you set the group and the transform, the selectability will come from the shape below, if the shape’s override is enabled. (If the shape override isn’t enabled, it will get it from the lowest transform’s override that is enabled.)

You can also put all your mesh shapes in a single displayLayer, so you only need to connect one attribute. If you create a displayLayer node from scratch, it doesn’t show up in the layer list, so it can be nice and clean, hidden from the animators. (In which case, you would add or remove nodes from the layer using Python.)

maya.cmds.createNode('displayLayer', n='test')

thank you, haven’t thought about shapes. Good call!