{"id":103,"date":"2013-06-13T01:09:39","date_gmt":"2013-06-12T15:09:39","guid":{"rendered":"http:\/\/alrichardson.com\/?p=103"},"modified":"2013-06-13T01:13:04","modified_gmt":"2013-06-12T15:13:04","slug":"zeroing-out-or-in","status":"publish","type":"post","link":"https:\/\/alrichardson.com\/?p=103","title":{"rendered":"Zeroing out. Or in."},"content":{"rendered":"<p>Today I wrote a little tool that simply groups whatever you have selected, for the purposes of cleaning up transforms. Also works with multiple objects selected and groups them all under a group in the same worldspace as the first selected object.<br \/>\nGrab the code here and place it on your shelf.<\/p>\n<pre class=\"lang:python decode:true\">import maya.cmds as cmds\r\nimport maya.OpenMaya as om\r\n\r\ngrpList = cmds.ls(sl = True)\r\n\r\nparentObj = cmds.listRelatives( grpList[0], parent = True )\r\ncmds.group( em = True, name = grpList[0] + '_Zero_GRP' )\r\ncmds.parentConstraint( grpList[0], grpList[0] + '_Zero_GRP' )\r\ncmds.delete( grpList[0] + '_Zero_GRP_parentConstraint1' )\r\ncmds.scaleConstraint( grpList[0], grpList[0] + '_Zero_GRP' )\r\ncmds.delete( grpList[0] + '_Zero_GRP_scaleConstraint1' )\r\ncmds.parent( grpList[0], grpList[0] + '_Zero_GRP' )\r\ntry:\r\n    cmds.parent( grpList[0] + '_Zero_GRP', parentObj )\r\n    om.MGlobal.displayInfo( grpList[0] + ' now has a group above it' )\r\nexcept:\r\n    om.MGlobal.displayInfo( grpList[0] + ' has no parent object, grouped in world space' )\r\n\r\ncmds.select( grpList[0] )\r\nnewParent = cmds.listRelatives( parent = True )\r\nlistEndNumber = len(grpList)\r\nremainingObj = grpList[1:int(listEndNumber)]\r\n\r\nfor i in remainingObj:\r\n    cmds.parent( i, newParent )\r\n\r\nom.MGlobal.displayInfo( grpList[0] + ' now has a group above it' )<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I wrote a little tool that simply groups whatever you have selected, for the purposes of cleaning up transforms. Also works with multiple objects selected and groups them all under a group in the same worldspace as the first selected object. Grab the code here and place it on your shelf. import maya.cmds as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,3,5,20,7],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-coding","category-maya","category-python","category-tips","category-tools"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103"}],"version-history":[{"count":3,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}