Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toggling X-ray with MEL in Maya 2019

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
6433 Views, 7 Replies

Toggling X-ray with MEL in Maya 2019

Hi. I've been trying to write an auto toggle for X-ray display mode, but it doesn't seem to work as I expect it to.

I found this answer dating 2017 on StackOverflow, but it doesn't seem to work anymore:

https://stackoverflow.com/questions/47829412/toggle-xray-for-selected-object-in-maya-with-script

as

displaySurface -q -xRay

always returns a zero value, no matter what.

I noticed that maya now uses "setXrayOption" command for this, but I couldn't find any info about it on the 2019 command reference page.

7 REPLIES 7
Message 2 of 8
mspeer
in reply to: Anonymous

Hi!

 

1. displaySurface is for selected objects and setXrayOption for whole Viewport

 

2. displaySurface -q -xRay;

returns a result based on per Object setting only.

Message 3 of 8
Anonymous
in reply to: mspeer

Thanks, that makes sense!

However, I am still wondering, whether there is a way to find out whether X-ray is on for the viewport, so I can put it into an if loop. Is there by any chance a command that returns its value?

Message 4 of 8
mspeer
in reply to: Anonymous

Hi!

Use modelEditor command.

 

Example:

 

//Enable xray
modelEditor -e -xray true modelPanel4;
//Disable xray
modelEditor -e -xray false modelPanel4;
//Query xray
modelEditor -q -xray modelPanel4;
Message 5 of 8
Anonymous
in reply to: mspeer

Great! Thank you, this is exactly what I needed  🙂

Message 6 of 8
shrigendraU7HTR
in reply to: mspeer

is there any way i can set the hotkey?

 

 

Message 7 of 8
mspeer
in reply to: shrigendraU7HTR
Message 8 of 8
mykotron
in reply to: mspeer

This doesn't work for me. I'm using Maya 2019

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report