Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ASSIGNMENT 4 Part 2
- import maya.cmds as cmd
- def #working on this function
- if cmd.ls(sl=True):
- parents = cmd.ls(sl=True)[-1]
- children = cmd.ls(sl=True)[:-1]
- def match_translation():
- for obj in children:
- cmd.matchTransform(obj,parents,pos=True)
- def match_orientation():
- for obj in children:
- cmd.matchTransform(obj,parents,rot=True)
- def match_scale():
- for obj in children:
- cmd.matchTransform(obj,parents,scl=True)
- def match_all_transforms():
- match_translation()
- match_orientation()
- match_scale()
- def delete_history():
- for obj in cmd.ls(sl=True):
- cmd.delete(ch=True)
- def center_pivot():
- for obj in cmd.ls(sl=True):
- cmd.xform(cp=True)
- def freeze_translation():
- cmd.makeIdentity(a=True, t=True)
- def freeze_orientation():
- cmd.makeIdentity(a=True, r=True)
- def freeze_scale():
- cmd.makeIdentity(a=True, s=True)
- def freeze_all_transforms():
- freeze_translation()
- freeze_orientation()
- freeze_scale()
- if cmd.window("myWindow", ex=True):
- cmd.deleteUI("myWindow")
- cmd.window("myWindow", t="Transformation Tool", w=300, h=300)
- cmd.columnLayout()
- cmd.rowColumnLayout(nc=3)
- cmd.checkBox(w=100, h=50, al="center", l="Match T", bgc=(1,0,0), onc=match_translation)
- cmd.checkBox(w=100, h=50, l="Match R", bgc=(0,0,1), onc=match_orientation)
- cmd.checkBox(w=100, h=50, l="Match S", bgc=(0,1,0), onc=match_scale)
- cmd.setParent("..")
- cmd.rowColumnLayout(nc=1)
- cmd.button(w=300, h=50, l="Match All Transforms", bgc=(1,1,1), c=match_all_transforms)
- cmd.setParent("..")
- cmd.rowColumnLayout(nc=1)
- cmd.button(w=300, h=50, l="Zero Out All Transforms", bgc=(.5,.5,.5), c=match_all_transforms)
- cmd.setParent("..")
- cmd.rowColumnLayout(nc=2)
- cmd.button(w=150, h=25, l="Delete History", bgc=(1,1,1), c=delete_history)
- cmd.button(w=150, h=25, l="Center Pivot", bgc=(1,1,1), c=center_pivot)
- cmd.setParent("..")
- cmd.rowColumnLayout(nc=3)
- cmd.button(w=100, h=25, l="Freeze T", bgc=(1,0,0), c=freeze_translation)
- cmd.button(w=100, h=25, l="Freeze R", bgc=(0,0,1), c=freeze_orientation)
- cmd.button(w=100, h=25, l="Freeze S", bgc=(0,1,0), c=freeze_scale)
- cmd.setParent("..")
- cmd.rowColumnLayout(nc=1)
- cmd.button(w=300, h=25, l="Freeze All Transforms", bgc=(1,1,1), c=freeze_all_transforms)
- cmd.setParent("..")
- cmd.showWindow("myWindow")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement