Hey guys!
I’m starting to learn how to use python in maya and I found some difficulties along the way…
Because my rigging exprience I found useful to write a script to help me changing the rotation order for selected objects.
I finished building a very simple UI with a optionMenuGrp and a button to confirm the rotation order.
My difficulty is to actually understand how to connect each element to each part.
So for example, in the def selObjs(): I want to know what value of the list is selected and update it when you select other item, so I can connect them with the rotateOrder attribute for the selected objects. Am I thinking properly?? Do I have to convert each item into an int??
Sorry for the very basic questions, but I have to start somewhere… eheheh! I’ve been reading a lot of documentation, but sometimes it’s difficult to find even a simple solution. :curses:
Thanks a lot :D:
import maya.cmds as mc
def aa_rotOrderUI():
"""Creates a UI for the aa_rotOrder."""
# Deletes window and window preferences if they exist
if mc.window("rotOrderUI", exists=True):
mc.deleteUI("rotOrderUI", window=True)
if mc.windowPref("rotOrderUI", exists=True):
mc.windowPref("rotOrderUI", remove=True)
# Creates UI window
window = mc.window("rotOrderUI", title="aa_rotOrder_V1.0")
formLayoutUI = mc.formLayout(nd=100)
aa_rotOrderOMG = mc.optionMenuGrp(label="Rotation Order: ", cw=[1, 115])
xyzItem = mc.menuItem(l="XYZ")
yzxItem = mc.menuItem(l="YZX")
zxyItem = mc.menuItem(l="ZXY")
xzyItem = mc.menuItem(l="XZY")
yxzItem = mc.menuItem(l="YXZ")
zyxItem = mc.menuItem(l="ZYX")
aa_btnUI = mc.button(l="Set Rotation Orders", width=200)
mc.formLayout(formLayoutUI, edit=True, attachControl=[aa_rotOrderOMG, "bottom", 15, aa_btnUI])
mc.showWindow(window)
def selObjs():
"""List selected objects."""
sel = mc.ls(selection=True)
def selectItem():
"""Selects the item in the dropdown list."""
selItem = mc.optionMenuGrp(aa_rotOrderOMG, query=True, value=True)
print selItem