def paste(shader, uv, color): # try because of error when selection is empty. mel command handles it without error. # noinspection PyBroadException try: m.polyClipboard(paste=True, shader=shader, uv=uv, color=color) except: pass
def gtu_paste_material(): ''' Copies selected material to clipboard ''' try: cmds.polyClipboard(paste=True, shader=True) except: cmds.warning( 'Couldn\'t paste material. Make sure you copied a material first, then selected the target objects or components.' )
def gtu_copy_material(): ''' Copies selected material to clipboard ''' selection = cmds.ls(selection=True) try: mel.eval('ConvertSelectionToFaces;') cmds.polyClipboard(copy=True, shader=True) cmds.inViewMessage(amg='Material <hl>copied</hl> to the clipboard.', pos='midCenterTop', fade=True) except: cmds.warning( 'Couldn\'t copy material. Make sure you selected an object or component before copying.' ) cmds.select(selection)
def copy(): polygons = m.ls(m.polyListComponentConversion(tf=True), fl=True, l=True) if polygons: m.polyClipboard(polygons[0], copy=True, shader=True, uv=True, color=True)