Skip to content

Instantly share code, notes, and snippets.

@land-Y
Last active May 27, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save land-Y/c4c83054b18bcf20faee1ceb8a0ccd13 to your computer and use it in GitHub Desktop.
Save land-Y/c4c83054b18bcf20faee1ceb8a0ccd13 to your computer and use it in GitHub Desktop.
MAYA2019 選択したノードをロケーター、またはトランスフォームノードの子供にして纏める
# -*- coding: utf-8 -*-
import maya.cmds as mc
def GroupNull(oName,oNull):
oList = mc.ls(sl=True)
#もし何も選択してないならエラー
if oList == []:
print ("Need select Objects")
else:
#objの中が1ならロケーター、0ならグループ
oList = mc.ls(sl=True)
oP = mc.listRelatives(oList[0], p=True)
if oNull == 0:
oGr = []
oGr.append(mc.group(em=1, w=1, n=oName + "{:03d}".format(0)))
print oGr
else:
oGr = mc.spaceLocator(r=True, n=oName + "{:03d}".format(0))
oSL = mc.ls(sl=True, dag=True, type='shape')
mc.setAttr(oSL[0] + ".visibility", 0)
print oGr
#親子化
oList = oList + oGr
print oList
mc.parent(oList)
#ワールドルートなら実行しない
if oP != None:
newList = oGr + oP
mc.parent(newList)
#グループノードの名称。トランスフォームなら0、ロケーターなら1
GroupNull("GroupNull_",0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment