Posts

Showing posts from August, 2012

PyMel- Getting texture file from a material

So, my first inelegant-yet-functional PyMel script is done and working. The core of it is in this little snippet here, that digs through a mesh's inputs until it finds the texture node on the surface shader: #Pass through the mesh's shape and return a texture name. import pymel as pm def getTextureFile(geo): sg = [] #Get the shading group from the selected mesh raw_sg = pm.listConnections(geo, type='shadingEngine') #Rapidly check for duplicates in the list- I do this by checking each item #against an empty list. #If the item is not in the empty list I append it. for element in raw_sg: if element not in sg: sg.append(element) #Get some info sgInfo = pm.listConnections(sg[0], type='materialInfo') fileNode = pm.listConnections(sgInfo[0], type='file') textureFile = pm.getAttr(fileNode[0].fileTextureName) print 'This is the file', str(textureFile) return str(textureFile) It st

Getting Maya to talk to Photoshop

Sadly, at work I am not blessed with the latest and greatest Maya versions, and I have to be content with Maya 8.5. That also means I have to be content with Python 2.4.2 in Maya... eh. Its enough to do some cool stuff. It has been a little pet project of mine to get Photoshop and Maya to talk to each other and share texture information (like texture file locations, etc etc) and after a bit of fussing around, and a total failure to get comTypes to work (missing ctypes module in py 2.4) I have been able to get the win32com module to work within the Maya Python 2.4.2 scripting environment. I don't think its going to be a two way street, but it does mean I can open a model's source PSD file(s) in Photoshop from within Maya. Kinda a neat little workflow thing. If anyone wants to share a better method give me a shout! -Pete

Python, windows and easy install...

Hey peeps, been pretty busy through project crunch but thought I'd post something I found useful. If you are scripting with python on a regular basis and want to take advantage of additional modules you are eventually going to come up against the ironically named easy_install. I script in Python, why should I care about easy install?  That's an excellent question, me. Easy install, once set up, can automatically download and install modules on request from the command prompt. Just type in the name of the module you want and easy install will download and set it up for you. The only caveat is installing the installer, which presents all sorts of hiccups if you have never poked around at your system's environment variables before. If you are having any issues with getting it running on windows, this blog was of immense help to me. I gotta say, even with the pain of getting it set-up (wasn't so bad when explained well) its well worth it! -Pete --- Edit: I noticed that the