Ralf_Reddings
Ralf_Reddings

Reputation: 1555

How to get names of hidden object(s) that are still selected?

I am trying to create a simple command that will toggle the visibility of the selected object, essentially running either (Display > Show) Show Selection or (Display > Hide) Hide Selection.

I came up with the following:

//simulates _display > show > show selesction | _display > hide > hide selection
$sel        = `ls -selection`;
if (`getAttr $sel.visibility`)
    HideSelectedObjects;
else
    ShowSelectedObjects;

It was working at first but after a few tries it broke on me, I keep getting the error:

// Error: No object matches name: .visibility

I have not changed my selection between firing the command, not even clicked on anything. The only way I can get it to work is by clicking on the hidden object in the outliner. I guess, I am essentially trying to figure out how Maya's Show selection finds the selected objects name.

I am on Maya 2024.

Upvotes: 0

Views: 20

Answers (0)

Related Questions