## Getting geo from later versions of Maya to earlier versions…

Fri, Feb 19th, 2016

Sometimes you need to get stuff back to earlier versions of Maya and ignore version just doesn’t work. I needed to get a load of 2016 geo back to 2011. Here’s what worked:

1. Export geo to a clean file in your current version of Maya
2. If you can’t export it as an .ma file, run scene optimize on the mb file making sure to remove unknown nodes
3. Save as an .ma
4. In a text editor change the 2016(or whatever version you’re going from) to 2011(or whatever version you’re going to). Save it
5. Open in the earlier version of Maya

-j@cgm

Sat, Feb 13th, 2016

Because google doesn’t always get them the first go…

## Adding attributes to sets in maya…

Fri, Jun 15th, 2012

So got a couple of queries on how you actually add attributes to sets in practice.

When cgm.setTools creates a set with selected channel box attributes on the fly, there are a couple of processes going on.

1. A set is created
2. The channel boxes are queried for selection via the function cgm.lib.search.returnSelectedAttributesFromChannelBox
3. There’s an active selection query for regular objects
4. Objects and selected attributes are added to that set

Sometimes you just wanna do stuff  yourself so here’s a few examples. Here’s an example of adding an attribute to an existing set. So in this case, the existing set is ‘point_lightSet’ and the attribute is ‘nurbsSphere1.translateX’:

import maya.cmds as mc
setName = 'point_lightSet'
attribute = 'nurbsSphere1.translateX'
mc.sets(attribute,add =setName)

If you just wanted to create a set from a list of attributes,  you’d wanna call that list into the sets command like this:

mc.sets([listOfAttributes])

I’m curious if anyone out there has an older version of maya (<2011) that this doesn’t work on. Maybe it didn’t allow for this at one point in time and I missed when it changed.

## A set by any other name…

Mon, Jun 4th, 2012

…isn’t necessarily a quick select set.

So, I learned I’d been going in the wrong direction for a couple of weeks on the buffer front. A bit frustrating? Yes. However, plenty of stuff learned. Failure is learning. And the faster you admit it, the faster you can start a new path. Hopefully the right one!

The main reasons I’d thought we needed a custom buffers turned out to not be true, it just so happens that Maya’s documentation is about as clear as mud on that front.

Here’s some useful tidbits:

• A quick select set is just a regular maya set that has it’s ‘text’ tag set to be ‘gCharacterSet’.  As far as I can tell that is the only difference at all.
• You can indeed add attributes to a set. I’d thought for ages you could only do objects and components. If Only I’d known…
• Anim curves can be added as well
• Sets can be flagged to only accept certain component types. However, the list is rather limited (verts, edges, faces, editPoints)
• If you add a set to another set, it’s like parenting them. Removing is like unparenting.

Regardless, been reworking the tools and the base functions are pretty much there. Just working through the GUI stuff. Hoping to have cgm.setTools up in the release later this week for testers.

Cheers!

## if maya.env(): return frustration…

Tue, Mar 27th, 2012

So at least to me, the maya.env setup has perpetually been an exercise in frustration. For years, it seemed it would remain shrouded in mystery. Recently as I’ve been making tools and learning I took some time to do some googling and I have a much better understanding of how to make it work  well so you don’t have to!

So, let’s set it up…

Homework first!

On a typical pc install, that will be ‘ \My Documents\maya\%version\’. In my case, it’s ‘X:\My Documents\maya\2011-x64’
2. Remember where you installed the cgmtools repository to

Let’s get to it.
Note – this is for a Windows setup

1. Make sure Maya is closed
2. The first thing we wanna add is an inline variable we can call. This doesn’t have to be done but with multiple repositories, I found it easier. We’ll add this to the top
REPOSPATH = X:/repos/
3. Then if you already have some paths on Maya_Script_Path or PythonPath, you can amend them by putting the following at the end of each one followed by a ‘;’
%REPOSPATH%/cgmtools/mayaTools; %REPOSPATH%/cgmtools/mayaTools;
4. Open up Maya and type the following in a mel command line:
cgmToolbox

Here’s an example of a clean maya.env with no other paths added.

[crayon]REPOSPATH = X:/repos/

MAYA_SCRIPT_PATH=%REPOSPATH%/cgmtools/mayaTools;

PYTHONPATH=%REPOSPATH%/cgmtools/mayaTools;[/crayon]

## Wing IDE auto completion in maya…

Thu, Mar 22nd, 2012

…with as little hair pulling as possible…

So, setting up an IDE for doing coding is a pretty good idea if you’re gonna be doing a lot of it. My IDE of choice is Wing and it can be a little tricky getting things setup right for auto-completion. If you wanna get going with it, you can…

2. Add maya’s mayapy exec as a custom Python Executable in Project Properties>Enviornment
3. Add your repository as a custom Python path in the same section – in my case ‘J:\repos\cgmtools\mayaTools’
4. Next see their doc page for maya for help
1. I had to change one item for my own setup. Maya 2011’s pi file location ended up being:
C:\Program Files\Autodesk\Maya2011\devkit\other\pymel\extras\completion\pi
5. Add your own computer’s path in Preferences>SourceAnalysis>Advanced>Insert and put that path in there and you should be golden
If you have to generate your own pi files for whatever reason…
Start with the tutorial here to get you most of the way there.
1. Now, when get to the the part about the genmayapi thing, you’re gonna wanna edit it cause it won’t work off the bat depending on your version of Wing.
1. Lines 5 and 7 will need to be modifed to your version of Wing. In my case, it was ‘Wing IDE Personal 4.1’
2. Line 12 will again need soe work, in my case it was ‘Wing Personal 4’.
You can find the folder directly in windows at  C:\Users\%Name%\AppData\Roaming.
2.  After those fixes you should be able to run the genmayapi and finish out the tutorial without issue.
This was my genmayapi.py:

[crayon]import os
import sys
import maya.standalone

WING_DIR = r’c:\Program Files (x86)\Wing IDE Personal 4.1′
if not os.path.exists(WING_DIR):
WING_DIR = r’c:\Program Files\Wing IDE Personal 4.1′

sys.path.append(os.path.join(WING_DIR, ‘src’, ‘wingutils’))
import generate_pi

PI_FILES_DIR = os.path.join(os.environ[‘AppData’], ‘Wing Personal 4’, ‘pi-files’)
MOD_LIST = [
‘maya.OpenMaya’,
‘maya.OpenMayaAnim’,
‘maya.OpenMayaCloth’,
‘maya.OpenMayaFX’,
‘maya.OpenMayaMPx’,
‘maya.OpenMayaRender’,
‘maya.OpenMayaUI’,
‘maya.cmds’,
‘maya.standalone’,
]

def main():
maya.standalone.initialize()
for mod in MOD_LIST:
pi_filename = os.path.join(PI_FILES_DIR, os.sep.join(mod.split(‘.’)) + ‘.pi’)
if not os.path.isdir(os.path.dirname(pi_filename)):
os.makedirs(os.path.dirname(pi_filename))

print ‘Generating .pi file for’, mod

f = open(pi_filename, ‘w’)
try:
generate_pi.ProcessModule(mod, file=f)
finally:
f.close()

if __name__ == ‘__main__’:
main()
[/crayon]

Happy coding!