Toggle Visibility

I wrote this a while ago but only remembered to post it up after having to reconfigure Maya – I was fed up of ctrl+h only hiding objects rather than properly toggling visibility so I wrote a script that will correctly toggle visibility on/off on selected objects. If you have a group of objects selected and half of them have visibility on and half have visibility off, it will turn the ones that were off to on and vice versa.

import maya.cmds as mc
selectedNodes = mc.ls(selection=True)

for selectedNode in selectedNodes:
currentVis = mc.getAttr(“{selectedNode}.visibility.”.format(selectedNode=selectedNode))
if currentVis == 0:
mc.setAttr(“{selectedNode}.visibility.”.format(selectedNode=selectedNode), 1)
else:
mc.setAttr(“{selectedNode}.visibility.”.format(selectedNode=selectedNode), 0)

In windows >settings/preferences > hotkey editor, I added this script to a new action (to replace the previous hide selected objects, which is in the display tab) – with the below settings (remember to reassign the hotkey <ctrl+h> to it (or whichever you prefer) and to make sure you’ve selected python rather than MEL.

// Error: File contains unknown nodes or data. To preserve this information, the current file type cannot be changed. //

So a lot of the times when I receive a .mb file containing a model to rig the first thing I want to do is set-up my projects, rename my scenes and save a version 00 to .ma – however every so often this message pops up:

// Error: File contains unknown nodes or data. To preserve this information, the current file type cannot be changed. //

Which refuses to let me save to a Maya Ascii file. Searching around I have found 2 fixes for this:

a) Force Maya to change the scene file type by executing the MEL code (keeps unknown nodes):

file -type "mayaAscii";

b) Deleting all unknown nodes in the scene by executing the MEL code:

delete `ls -type unknown -type unknownDag -type unknownTransform`

Changing the key in Fedora17 so you can move around Maya…

The problem with running Maya on Fedora is that by default, when you hold the alt key it will drag the current window around. Now, Maya users need the alt key to be free as we use ALT+LMB etc. to move around our view-panel. They’ve changed the way to do this in fedora 17 from 16 a little so here is the new method:

1. By default, dconf-editor is installed in F17. Open it.
2. Go to org > gnome > desktop > wm > preferences
3. Scroll down to mouse-button-modifier and change it from “” to “” (The windows key on a standard keyboard – or whichever key you prefer)
4. Voila!