Python

Autodesk just recently released Maya 2017. Which means another round of updates for my two available plugins; sePushPullConstraint and seUVBlendShape. The big change this time around was the update to Qt version 5. Though the conversion from version 4 to 5 is not that difficult, it does make it incompatible between the two versions. Thankfully, someone has already wrote a nice Python module to make the code work in both. So for those tools that are using PyQt and want to make their user interfaces compatible, take a look at this handy code.

That’s all the updates for now! Enjoy!

If you have used dock widgets in Qt, you may have docked with with tabs for easy stacking of other dock widgets. One handy feature of the tabs is when you click on the active tab, it will collapse the dock area and clicking a tab will expand it again. One thing however that is missing in Qt is a way to trigger this behavior yourself. If you simply hide the dock widget, the tab will disappear so that is no use. There is no slot or function to control the action. After lots of investigating I came to the conclusion that there is some custom Qt event handling specifically for mouse button clicks on a dock widget tab.  Triggering this event causes some way to hide the dock but keep the tabs using some other special method. The Qt source code doesn’t expose this either so there is no way to find what is happening and recreate it yourself.

But I didn’t give up, I wanted my tabbed dock widgets to be collapsed upon opening the UI to keep tools that are not needing to be seen from distracting the user. So how can I trigger this behavior programmatically? Well, I simulate a mouse button click event on the tab so I trick Qt on thinking the user did click on the tab! By creating my own QMouseEvent, I send the event to the tab bar with the position of where the “click” happened and let the tab bar handle what it does, which is collapse/expand the dock widget. Simple!

Below is the code snippet I created to reproduce a mouse button press event over the tab that has the same text. Simply pass it a QMainWindow instance and the text on the tab you want to “click” on.  The return will be True if the tab was found and event was sent otherwise False. Now you can too programmatically trigger this feature which should have been included in the first place. By the way, this is for Qt 4.8, maybe future versions will support this.

 

I needed a way to get the geometry index on a deformer based on the deforming shape name. Rather than trying to trace the connections in the dependency graph, Maya’s API has a much easier and faster method. This is also better than using the deformer command for the information since the command does not support returning full path names for comparison. So I thought I would share it to anyone who may want to add it to their own collection of tools.

 

A friend and former co-worker Chad Vernon does it again with his awesome skills. This time Chad has released a free tool to generate front of chain corrective shapes on an already deformed mesh.

Meaning, if you are trying to find an easy way to sculpt a corrective shape on a posed mesh, this will create a mesh that can be used in a blend shape at the beginning of your deformation chain which you can drive that shape when the other deformations put it in that pose. It makes doing corrective shapes so much easier than trying to guess or having a custom additive blend shape deformer.

What really makes Chad a nice guy is he provided the code in all python for you to look and see. Thanks Chad, I’ll be sure to use this soon! So go over there and get it now!

http://www.chadvernon.com/blog/resources/cvshapeinverter/

In the spirit of sharing some handy scripts and tools, as well as pushing my vote toward PyMEL. I am going to try to post some handy code snippets to copy and paste for your own uses. This is nothing big or fancy, mostly just small functions that are good to have in a library.

This particular function is for renaming a node in Maya to be uniquely named if it isn’t already. You can use this in a loop to make sure you don’t have any duplicate node names. This is designed to use PyMEL objects. So enjoy and hopefully more of these type of snippets will be posted.

I made this code that works with PyMEL version 1.0.0 which comes with Maya 2011.