def addGroupAbove(obj="none", suff="none", *args):
"""name of existing obj, new group suffix. New group will be oriented to the object BELOW it"""
#FIX THE OBJ, SUFIX TO BE EITHER SELECTED OR ENTERED
sel = cmds.ls(sl=True, type = "transform")
for obj in sel:
suff = "_new"
name = obj + suff + "_GRP"
#get worldspace location of existing obj
loc = cmds.xform(obj, q=True, ws=True, rp=True)
#create new group, name it, move it to new postion in ws and Orient it
grp = cmds.group(empty=True, name=name)
cmds.move(loc[0], loc[1], loc[2], grp, ws=True)
oc = cmds.orientConstraint(obj, grp)
cmds.delete(oc)
#check if there's a parent to the old group
par = cmds.listRelatives(obj, p=True)
print(par)
if par:
cmds.parent(grp, par)
cmds.parent(obj, grp)
评论列表
文章目录