Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How to call the create layer script when clicking the create layer button from the menu.
I don't know how to make the call from a button to the create layer code. And looking for help in the forums I'm lost because it's so vast.
MENU:
import maya.cmds as cmds
def showUI():
myWin = cmds.window(title="Add layer", widthHeight=(260, 52))
cmds.columnLayout()
cmds.button(label="Add to Layer",width=258,align='center', command=buttonFunction)
cmds.separator()
cmds.button(label="test",width=258,align='center', command=buttonFunction)
cmds.showWindow(myWin)
showUI()
CREATE LAYER:
import maya.cmds as cmds
def makeAnimLayer(layerName):
baseAnimationLayer = cmds.animLayer(query=True, root=True)
foundLayer = False
if (baseAnimationLayer != None):
childLayers = cmds.animLayer(baseAnimationLayer, query=True, children=True)
if (childLayers != None) and (len(childLayers) > 0):
if layerName in childLayers:
foundLayer = True
if not foundLayer:
cmds.animLayer(layerName)
else:
print('Layer ' + layerName + ' already exists')
makeAnimLayer("Layer")
cmds.animLayer("Layer", edit=True, addSelectedObjects=True, selected=True)
Solved! Go to Solution.