Ever came across the situation of needing a space to work one way and in the next moment exactly the opposite way? Was your conclusion a 2nd control to avoid cycles in Maya? (Scroll to short answer) Long answer Imagine the situation of having a weapon in the rig for instance – some animators might just want the hands to follow the rifle, makes sense, right? But some animations using the same rig are made for a pistol instead – it’s understandable that your animators might want to animate the right arm instead of the weapon control. You come up with a smart way of making the left hand having a right hand space and a world space to accommodate for this. Then out of nowhere the direction says that you’ll need to support a left handed weapon animation. It gets more and more complicated and it can be very […]
Hi guys, In a few days I am going to post my way of doing space switching perfectly avoiding cycles. I will show how to create spaces where you can for instance have the left hand follow the right hand and the other way around – in one rig and with logic node networks only. Check back this week for an in depth tutorial how to do that. You’ll love it and it’s not even difficult.
Whenever you want something to happen when your selection in Maya changes, the first thing that comes into your mind might be Maya ScriptJobs. However I find them very slow and not reliable, especially since they are wrapped in mel. Better use a callback from OpenMaya’s messaging system. This is how you do it: You will have to create a function that is called every time the selection changes. Make it run fast and with lots of error checking to avoid making your tool too slow. In your function, get the selection and evaluate what you want to do with it. The function could look something like this:
from maya import OpenMaya
#function to execute when selection changes
def maya_selection_changed(*args, **kwargs):
sel = OpenMaya.MSelectionList()
selection_iter = OpenMaya.MItSelectionList(sel)
obj = OpenMaya.MObject()
# Loop though iterator objects
while not selection_iter.isDone():
# Now we can do anything with each of selected objects.
# In this example lets just print path to iterating objects.
dagPath = OpenMaya.MDagPath.getAPathTo(obj)
except RuntimeError, err:
Don’t worry, you don’t have to use maya API but you can use pymel or even maya.cmds instead. In my example I just print the names of the selected nodes however I would avoid any prints as they are slowing down […]
When working with different 3D applications you might have to convert between left handed and right handed coordinate system from time to time. The math behind this is quite simple. You have to create an inversion matrix that indicates which axis is inverted in one of the apps. In the following example we convert coordinates between Maya in Y-UP and Unity in Y-Up. Looking at the coordinate system in maya and unity you will realise that X-axis is inverted.. In Maya the x axis points in the opposite direction as in unity. This means, when the x translation is positive in Maya, it will be negative in Unity. For translations this is really simple, you can just invert thethe maya translate X channelbox value to get the correct coordinates for Unity. But as soon as rotations are in play as well it is not that simple anymore. Here is how […]
When working on multiple projects you might want to use assets from other projects. Very often a file referencing pipeline makes this difficult though as Maya stores file references with absolute paths when you are not using Maya projects. To avoid this you can hijack the Referencing procedure with a callback.
The callback triggers any function you define. In the function you have access to the file path of the reference to do some checks and you can cancel the loading of the reference or manipulate the path to your liking. Create a function somewhere in your pipeline. Your function needs 3 parameters: parameter 1 is the return code (a boolean to approve or cancel the reference load operation) parameter 2 is the file object which holds the path and file information parameter 3 is client data which you can pass in to your function from the callback
def callbackFunction(retCode, fileObject, clientData):
# printing the original file path
print "Original file path %s" % fileObject.rawFullName()
# create a variable for the new file path
# maybe create some logic for that or even a condition whether to
# manipulate the path or keep the existing one
newFilePath = "C:/tmp/newFile.ma"
# set the file path to be loaded if you want to modify it
# here you can define whether the file should be loaded or
# whether the reference should be skipped
Creating a p4 workspace through command line is not that fast forward and the documentation about it is rather confusing. You want to set the Root Directory, some settings and the proper mapping. Here is how you set it up in your pipeline. First, create a client workspace manually and configure it as you want including the default mapping you want. This workspace is not to be used by a user but will be used as a template to inherit the mapping and some settings. Name it properly and make sure not to delete it. In my case I called it “templateWorkspace“ Now to the real magic – the command:
p4 -d [rootFolder] client -t [templateWorkspace] -o [nameOfNewWorkspace] | p4 client -i
[rootFolder] = client root folder [templateWorkspace] – an existing workspace with proper settings and mappings [nameOfNewWorkspace] – name of the new workspace you want to create Hope this helps some of you guys
I am back, hopefully this time with more python and maya goodies for your pipeline and solutions.