Nov 202011
 

A question came up in the Maya-Python mailing list that I thought was a really good topic, and should be reposted.

Someone asked how you can create maya UI objects and embed them within your main PyQt application. Specifically he wanted to create a modelPanel and embed it so that he would have a camera view within his own PyQt window.

Here is my example of how to achieve this…

You need sip and the MQtUtil functions to convert between maya node paths and python Qbjects. Its the same idea as having to use those functions to get a reference to the maya MainWindow, in order to parent your dialog.

Nov 152011
 

Second video in the python for maya series, just released through cmiVFX!

Python For Maya – Volume 2

If you watched the first video, you now have a good grasp on Python. Sweet. Let’s plow through some more involved concepts like python juggernauts!

With a working knowledge of the python scripting language, and the Maya Python commands API, we can continue to learn new ways to solve more challenging problems, create complete scripts, and build user interfaces around our tools. We also introduce the Maya Python API; a lower-level interface into Maya.

This video focuses more on breaking down full scripts, as opposed to typing out syntax. Its jam packaged with information and moves fast to deliver you as much brain food as possible. The first segment of the video transitions from beginning to intermediate level, with the majority of the video being intermediate, and finishing out by touching on advanced concepts. The included project files are abundant, complete, and full of helpful documentation so that you can take your time and learn about each piece of the tools.

If you check it out, leave me feedback!
http://cmivfx.com/store/328-Python+For+Maya+Vol+02

First video can be found here

Nov 092011
 

This is a follow up post to my previous one on Installing PyQt4 for Maya 2011

Recently while putting together my next video tutorial for Python for Maya, I came to a section where I wanted to demo PyQt4 in Maya2012. But I was concerned that viewers would have to go through the complicated steps of building PyQt4. I noticed that other people have made available precompiled PyQt installers for windows (here) but I could not find any for OSX or linux. So I decided to put together a build.

I created a new project on github called MyQt4
https://github.com/justinfx/MyQt4

Its a Makefile for completely downloading and building PyQt4 for maya, and generating a .pkg installer. Hopefully someone can contribute improvements since I dont have a ton of experience writing makefiles, and also that someone might create a linux version.

Here is a link to the latest pkg build:

Snow Leopard: 

Lion:  

Mountain Lion:

Here are builds other people have made:

Jan 072011
 

Update:

I am now hosting a built package for Maya2011: MyQt4.7.4-maya2011-x64-osx-10.6.pkg
And for Maya 2012+, see: Installing pyqt4 for maya2012


Personally, when trying to run PyQt from within Maya 2009/2010 using the pumpThread method, I never had much luck. The best I ever got was the ability to bring up a dialog but not without locking up the UI, even though the pumpThread tool is meant to address that.

Anyways, when I found out Maya 2011 was rewritten based on Qt for the UI, I was really stoked. I saw the example video of being able to design a ui file in Designer, and just directly open it in a maya script, and all I could think about was designing Qt GUIs so much more easily now. Turns out that Maya 2011 didn’t actually ship with PyQt included for licensing reasons I’m sure. But it included documentation on how one could go about building PyQt for maya. Unfortunately I had tons of issues that caused maya to just crash when importing PyQt.

What I finally figured out was a mish-mash of information from the maya documention, and different forums and user groups. So I decided to make this easier on anyone having the same problems as I did, and just collect that information into one place. This process is for OSX. I’m sure most of it is probably still relevant to linux or win, except for the last parts with ‘install_name_tool’. You would just need to make sure to find the right Qt/PyQt/SIP packages for your OS.

Building PyQt4 for Maya 2011 on OSX

Update for Maya 2012

While Maya uses newer versions, it seems the versions from the 2011 install still work. But here they are anyways incase you want the newer version for 2012:


Make sure you have downloaded and installed the latest XCode from Apple. Its also included on your OSX installation disc.

Qt: Maya has a specific version of Qt built into it. This is Qt 4.5.3.
  1. Download:  qt-mac-opensource-src-4.5.3.tar.gz
  2. Extract:
  3. Build and install:
SIP: The maya docs recommend sip version 4.10
  1. Download this specific SIP:   sip-4.10.tar.gz
  2. Extract:
  3. Build and install:
PyQt4: The maya docs suggest PyQt 4.7
  1. Download this specific PyQt: PyQt-mac-gpl-4.7.4.tar.gz
  2. Extract:
  3. Set up some environment variables before building:
  4. Build and install:
  5. PyQt4 will now be installed into Maya’s python site-packages, BUT will be linked against the wrong Qt binaries. The maya docs have an annoying multi step set of commands but they don’t copy/paste nicely, so here is a for-loop you can use:

At this point you should be able to start up Maya and import and run PyQt from the script editor. You no longer need the pumpThread. Here is a test code snippet that I borrowed from here (the original had typos in it that I corrected)

It doesn’t seem like you even need the install of Qt 4.5.3 that we did at this point since we changed the links, unless you use another Qt module besides QtCore, QtGui, QtSvg, QtXml, QtOpenGL (such as QtNetwork), but this could be solved by copying over the missing libs to where Maya is expecting them. Example for copying over QtNetwork:

If you happen to have a mixed library environment like me, with more than one python lib location for code, and you see any funny errors while importing a module, just make sure that mayas python site-package is always in the front of the sys.path:

And there you have it. PyQt4 now installed in Maya 2011 under OSX.


References:

Oct 082010
 
AtomSplitter

We finally decided to release the source code for AtomSplitter, since we were getting some feedback that the application builds weren’t 100% working on every possible system.

Project site:
http://redmine.justinfx.com/projects/atomsplitter

The current version is 1.6.2,  which adds the cmivfx chatroom to a tab, and some minor bug fixes. More info:
http://www.cmivfx.com/productpages/product.aspx?name=AtomSplitter_1.6

Update #1:

I have posted the AtomSplitter project on github now: https://github.com/justinfx/AtomSplitter

 

Aug 312010
 
AtomSplitter

 

AtomSplitter has been updated to v1.6, available through cmivfx.com

AtomSplitter 1.6 – cmiVFX.com

Updates:

  • Exports Terragen .tgd scene file format

See the original post.

May 112010
 
AtomSplitter

 

AtomSplitter (chanToFbx) has been updated to v1.2, available through cmivfx.com

AtomSplitter 1.2 – cmiVFX.com

Updates:

  • Camera rotation order set to ZXY, which is the Nuke camera default
  • Fixed a bug where the FocalLength value was not being keyframed properly
  • Added a scene scale field, for adjusting the translation values globally.

If you haven’t visited cmiVFX.com before, PLEASE check them out. Chris Maynard does an amazing job rounding up top talent in the industry to create these outstanding visual fx tutorials. The information is always cutting edge.

See the original post.

Mar 162010
 
taskMonster2

I get to do a lot of interesting applications at SouthPark. This one in particular was the most challenging use of PyQt that I have experienced to date.

The backstory….
The art department wanted a tool to help them track assigned tasks, the progress, and to share media and notes associated with the tasks. Furthermore, they wanted to be able to skin the interface with custom graphics to make it their own.

Progress…
During the winter break (about a month) I was able to come up with version 1.0 of TaskMonster. It was written in python, using PyQt for the UI, sqlalchemy to talk to the database, and twisted for the client/server communication. Each client app sends messages to a small server daemon which in turn tells the rest of the clients about the updates.

Version 2.0 Alpha…
Tony Postma, from the art department, put together a design in Corel which I could hopefully implement in the UI.  It called for the users to be represented as little pods in a circle around the supervisor, Adrien Beard. And each user pod could be clicked and rotated into place, in order to view that persons tasks.
After a bunch of testing I was able to design a rotating widget that could dynamically lay out N widgets around it in a circle, track their position, and jump to any other widget. I was also able to break down the corel->illustrator file, into a combination of SVG and PNG images, and skin the UI via CSS stylesheets.
Its currently an alpha release. I guess I need to really learn how to control the widget painting, to make it faster. Never had to do this much before.

What I came up with…        Click here to watch the demo video

Mar 102010
 

You know when you have all these widgets laid out in your class, and you are hooking up all the connections, and you say “Aw dammit I have to subclass QLabel now just so make it ignore blahEvent”? You end up with all these little widget subclasses, where all they are doing is ignoring an event.

I noticed I was doing this a few times, in more than one of my classes, and finally got annoyed for the last time. I figured there had to be a simple way of just overloading the method on the normal object when I create an instance. Fortunately python considers everything objects and pretty much anything can be changed. So I did this:

myLabel = QLabel()
myLabel.mousePressEvent = lambda event: event.ignore()

Magic.

I have also had to make clickable widgets, such as QLabel:

myLabel = QLabel()
myLabel.mousePressEvent = lambda event: myLabel.emit(SIGNAL("clicked"))

Or if you had to do more than just a single statement:

myLabel = QLabel()
def clickedEvent(event):
    myLabel.emit(SIGNAL("clicked"))
    # do other stuff
        # do stuff
    event.accept()
myLabel.mousePressEvent = clickedEvent

I like this better than piling up subclasses that don’t do much.