avatar
Untitled

Guest 368 19th Mar, 2019

PYTHON 1.06 KB
                                           
                         from maya import cmds
 
def run():
    sel = cmds.ls(sl=True)
    if len(sel) == 0:
        raise Exception("Must select meshes to kit bash.")
     
    orig_meshes = []
    for obj in sel:
        if not cmds.objectType(obj, isType="transform"):
            continue
        shapes = cmds.listRelatives(obj, fullPath=True, shapes=True)
        if shapes is None:
            continue
        if cmds.objectType(shapes[0], isType="mesh"):
            orig_meshes.append(obj)
     
    meshes = cmds.duplicate(orig_meshes, renameChildren=True)
    for i, mesh in enumerate(meshes):
        meshes[i] = cmds.parent(mesh, world=True)[0]
    cmds.select(meshes, replace=True)
    cmds.makeIdentity(apply=True, t=1, r=1, s=1)
    result = cmds.polyCBoolOp( meshes, op=1, n='kitbash_result', ch=False )[0]
    cmds.select(result, replace=True)
    remesh = cmds.polyRemesh(result)[0]
 
 
def safe_delete(objects):
    for obj in objects:
        if cmds.objExists(obj):
            cmds.delete(obj)

run()
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data