zbw_dupeSwap.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:zTools 作者: zethwillie 项目源码 文件源码
def dupeIt(*args):
    """uses the first selection and duplicates it to the transforms of the rest of the selected objects, with or without connections"""

    sel=cmds.ls(sl=True, type="transform", l=True)
    inputs = cmds.radioButtonGrp("inputsRBG", q=True, sl=True)
    if sel:
        base=sel[0]
        if len(sel)>1:
            objs=sel[1:]
            transforms = {}
            x=0

            for obj in objs:
                #get pos, rot, scale
                pos = cmds.xform(obj, ws=True, q=True, t=True)
                rot = cmds.xform(obj, ws=True, q=True, ro=True)
                scal = cmds.getAttr("%s.scale"%obj)[0]
                transforms[x] = [pos, rot, scal]

                #delete the obj
                cmds.delete(obj)
                x=x+1

            for key in transforms.keys():
                if inputs == 1:
                    dupe = cmds.duplicate(base)[0]
                elif inputs == 3:
                    dupe = cmds.duplicate(base, un=True, rr=True)[0]
                elif inputs == 2:
                    dupe = cmds.duplicate(base, ic=True)[0]
                print dupe
                cmds.xform(dupe, ws=True, t=transforms[key][0])
                cmds.xform(dupe, ws=True, ro=transforms[key][1])
                cmds.setAttr("%s.scale"%dupe, transforms[key][2][0], transforms[key][2][1], transforms[key][2][2])

#TODO - checkbox to copy inputs on orig objects to corresponding inputs on top level of duplicates

        else:
            cmds.warning("You need to select more than one object in order to swap!")
    else:
        cmds.warning("Please select some transform nodes to dupe!")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号