Skip to content

Instantly share code, notes, and snippets.

@hotcakesdeluxe
Created December 16, 2021 18:10
Show Gist options
  • Save hotcakesdeluxe/111c2a66edb62e8b098a0effaf417116 to your computer and use it in GitHub Desktop.
Save hotcakesdeluxe/111c2a66edb62e8b098a0effaf417116 to your computer and use it in GitHub Desktop.
def shapeReplacer(obj, crv):
selection=[]
shape=[]
if(obj == ""):
selection = cmds.ls(sl=True)
else:
selection = obj
shape = cmds.listRelatives(selection, f=True,s=True)
#this split to make sure that we don't delete shapes we are using for common controls added from the 'shapeParent' function
#those shapes return as separate strings in the same list index for some maya reason
x = shape[0].split(",")
if(len(shape)>0):
cmds.delete(x)
replacementShape = cmds.listRelatives(crv, f=True,s=True)
cmds.parent(replacementShape, selection, shape = True, add = True)
cmds.delete(crv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment