In Softimage, I use a lot the Match transforms' commands to match an object's position, orientation or scale to another. Although we don't have those in Maya, we can get around with snaps and some scripts appended to your shelf!
An easy way to do this in Mel is to use the delete command:
- Match position:
delete `pointConstraint`;
- Match orientation:
delete `orientConstraint`;
- Match All:
delete `parentConstraint`;
Another way is to match each attribute from source to target.
eg: Matching position in Python
import maya.cmds as c
sel = c.ls(sl=True)
ob = c.getAttr(sel[0] + ".t")[0]
c.setAttr(sel[1] + ".t",ob[0],ob[1],ob[2])
Another thing in Softimage that is widely used is Neutral Pose. It is always important to keep controllers zeroed. In Maya we can do this by grouping (Ctrl+G) or parenting to another object and match its transforms!
eg:
import maya.cmds as cmds
# Select group and then select child object
s = cmds.ls(selection=True)
# Get and Set objects' translation
v = cmds.getAttr(s[1] + ".translateX")
cmds.setAttr(str(s[0]) + ".translateX",v)
v = cmds.getAttr(s[1] + ".translateY")
cmds.setAttr(str(s[0]) + ".translateY",v)
v = cmds.getAttr(s[1] + ".translateZ")
cmds.setAttr(str(s[0]) + ".translateZ",v)
# Get and Set objects' rotation
v = cmds.getAttr(s[1] + ".rotateX")
cmds.setAttr(str(s[0]) + ".rotateX",v)
v = cmds.getAttr(s[1] + ".rotateY")
cmds.setAttr(str(s[0]) + ".rotateY",v)
v = cmds.getAttr(s[1] + ".rotateZ")
cmds.setAttr(str(s[0]) + ".rotateZ",v)
# Set child object's transforms
v = 0
cmds.setAttr(str(s[1]) + ".translateX",v)
cmds.setAttr(str(s[1]) + ".translateY",v)
cmds.setAttr(str(s[1]) + ".translateZ",v)
cmds.setAttr(str(s[1]) + ".rotateX",v)
cmds.setAttr(str(s[1]) + ".rotateY",v)
cmds.setAttr(str(s[1]) + ".rotateZ",v)
From Softimage to Maya!
Wednesday, 8 April 2015
Python, Qt and Maya!
One very interesting combination with Maya is Python and Qt!
Qt offers a huge range of tools to help us develop and create softwares.
http://www.qt.io/
Up to now, all I could do was create some interfaces for Maya... Qt Designer allows us to have some nice interfaces with simple drag'n drop and resize commands. With the help of PyQt libraries, we can quickly call those interfaces from Maya's shelf using Python!
This week I decided to start my AutoRig as a way to learn a little bit of rigging and scripting in Maya!
Here are some steps to get things working!
1) Install Qt, Python and PyQt (check if you're downloading for the same version);
2) Create a new Form->Widget in QtDesigner;
3) Set an objectName for each widget (eg: objectName: ObjTest);
4) Save the ui file (eg: test.ui);
5) Create a python script with the following content:
# -*- coding: utf-8 -*-
import maya.cmds as cmds
from PyQt4 import QtGui, QtCore, uic
ui_filename = '%PATH_TO_FILE/test.ui'
form_class,base_class = uic.loadUiType(ui_filename)
class testing(base_class, form_class):
def __init__(self):
super(base_class,self).__init__()
self.setupUi(self)
self.setObjectName('ObjTest')
self.connectInterface()
def connectInterface(self):
QtCore.QObject.connect(self.ObjTest, QtCore.SIGNAL("clicked()"),self.ObjTestCmds)
def ObjTestCmds(self):
print "It is working!"
def main():
global ui
ui=testing()
ui.show()
if __name__ == "__main__":
main()
Qt offers a huge range of tools to help us develop and create softwares.
http://www.qt.io/
Up to now, all I could do was create some interfaces for Maya... Qt Designer allows us to have some nice interfaces with simple drag'n drop and resize commands. With the help of PyQt libraries, we can quickly call those interfaces from Maya's shelf using Python!
This week I decided to start my AutoRig as a way to learn a little bit of rigging and scripting in Maya!
Baby steps to an AutoRig in Maya!
Here are some steps to get things working!
1) Install Qt, Python and PyQt (check if you're downloading for the same version);
2) Create a new Form->Widget in QtDesigner;
3) Set an objectName for each widget (eg: objectName: ObjTest);
Creating a basic form with a pushButton widget.
4) Save the ui file (eg: test.ui);
5) Create a python script with the following content:
# -*- coding: utf-8 -*-
import maya.cmds as cmds
from PyQt4 import QtGui, QtCore, uic
ui_filename = '%PATH_TO_FILE/test.ui'
form_class,base_class = uic.loadUiType(ui_filename)
class testing(base_class, form_class):
def __init__(self):
super(base_class,self).__init__()
self.setupUi(self)
self.setObjectName('ObjTest')
self.connectInterface()
def connectInterface(self):
QtCore.QObject.connect(self.ObjTest, QtCore.SIGNAL("clicked()"),self.ObjTestCmds)
def ObjTestCmds(self):
print "It is working!"
def main():
global ui
ui=testing()
ui.show()
if __name__ == "__main__":
main()
In this case, when I click on the pushButton, it calls the ObjTestCmds function.
Save the file (eg: testing.py)
6) In Maya, go to the Script Editor and type:
import sys
Dir = "%PATH_TO_FILE_FOLDER%"
if Dir not in sys.path:
sys.path.append(Dir)
import testing
testando.main()
I'm just appending the script directory to the system's Path variable and calling the python's class testing.
If everything goes ok, you should see something like this:
Qt Form in Maya!
And that's it!... Now you can do anything with Python, Qt and Maya!... \o/
Scripting and coding!
In Softimage we had:
- Script Editor
- Script Operator
- Expression
- and ICE!
And we could script with JScript, VBScript and Python!
In Maya we have:
- Connection Editor
- Script Editor
- Expression Editor
- Node Editor
And we can script in Mel and Python!
Maya offers a similar set of tools! So it will be a much smoother transition! \o/
- Script Editor
- Script Operator
- Expression
- and ICE!
And we could script with JScript, VBScript and Python!
In Maya we have:
- Connection Editor
- Script Editor
- Expression Editor
- Node Editor
And we can script in Mel and Python!
Maya offers a similar set of tools! So it will be a much smoother transition! \o/
Environment Variables and Shelves
As a softimage user, I got used to plug everything in Softimage's Workgroup. It is a simple tool to get things organized with yourself and mostly within your network.
Now in Maya we have other tools that can help me get organized!
First, environment variables. In Maya we can also use a batch script on startup to find your plug-ins. But in this case, it is user defined, that is, the script is stored in the users' folder. You can find it in %User_Folder%\Documents\maya\%Maya_Version%\Maya.env.
In this file, all you have to do is set variables and values (eg. Maya renderer path, Path, etc)
Second, shelves. I have to be honest. I didn't use Softimage's shelf at all. But in Maya, a lot of automation goes around shelves. And it is also created with a simple drag'n drop. So start creating one with your name and hang all your daily stuff there! But be careful! A lot of Softimage's commands does not exist in Maya. So it will be tempting to recreate them. This is ok, but it will quickly get crowded with tools! So get organized in the beginning to avoid a huge list of buttons as I did... O_O'
Now in Maya we have other tools that can help me get organized!
First, environment variables. In Maya we can also use a batch script on startup to find your plug-ins. But in this case, it is user defined, that is, the script is stored in the users' folder. You can find it in %User_Folder%\Documents\maya\%Maya_Version%\Maya.env.
In this file, all you have to do is set variables and values (eg. Maya renderer path, Path, etc)
Second, shelves. I have to be honest. I didn't use Softimage's shelf at all. But in Maya, a lot of automation goes around shelves. And it is also created with a simple drag'n drop. So start creating one with your name and hang all your daily stuff there! But be careful! A lot of Softimage's commands does not exist in Maya. So it will be tempting to recreate them. This is ok, but it will quickly get crowded with tools! So get organized in the beginning to avoid a huge list of buttons as I did... O_O'
One thing to keep in mind...
Well... the first thing that happens when we try to migrate from one software to another is to find the same old tools on your new set of tools. This is a wrong way to start... We will never find things we were confortable from long time on different concepts. We have to understand the new philosophy and try to find new ways to reach our goals. It gets nowhere to start your trip on comparison. "Oh, in Softimage it is easy to do this. In Maya we can't...". Let's pretend we are kids again! It is always fun to discover new roads! And often, new roads (good, bad, new, old, it doesn't matter) make you rethink your old way to do things! =D
Let's start!
I decided to create this blog to help me remember my studies in Maya!
Since the end of our beloved Softimage, I've restarted my 3D life in this new world called Maya!
If anyone would like to join or help me with this new journey, the doors are widely open!
And please correct me if I misunderstand any concept!
And please correct me if I misunderstand any concept!
Thanks for you visit! =D
Subscribe to:
Posts (Atom)