0

I've wrote this script to blendshape meshes on different position and be able to attach a new mesh automatically. I feel like this script is really noob as Im still learning and would love is somebody could help me make it more effecient.

The way how it works is you parent the New mesh to the Old Mesh (middle drag the new mesh to Old mesh) then selecting the Old Mesh to the multiple existing meshes then run the script. Make sure you freeze transform to the Old mesh and existing old mesh as well coz it uses blendshape to work.

please let me know if you guys need a video to better understand it as I know its abit confusing.

heres the script: \

import maya.cmds as mc

def parented_mesh():

    sel_obj = mc.ls(sl=True)
    driver = sel_obj.pop(0)
  
    
    for object in sel_obj:
    
        group_dup = mc.duplicate (driver, f =1, n= "Old_Source")
        child_rename = mc.rename(group_dup[-1] ,"New_Obj" + "#")
        unparent_child = mc.parent(child_rename, w=1)
        mc.select(unparent_child,group_dup[0])
        wrap_def = mc.CreateWrap(maxDistance = 1000)       
        mc.select(object)
        mc.select(group_dup[0],add = True)
        mc.blendShape(w=[(0, 1),])
        mc.delete(child_rename, ch = True)
        mc.select("*Base")
        mc.delete()
        mc.select("Old_Source")
        mc.delete()
        mc.select(child_rename)
        mc.CenterPivot()
        mc.BakeCustomPivot()

parented_mesh()
Alexey S. Larionov
  • 6,555
  • 1
  • 18
  • 37
Czar
  • 1
  • 1

0 Answers0