Created
October 4, 2014 10:02
-
-
Save mottosso/2e3ac775bdf01d5dd047 to your computer and use it in GitHub Desktop.
Select Selected - A Pyblish plug-in for Autodesk Maya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyblish.api | |
from maya import cmds | |
class SelectSelected(pyblish.api.Selector): | |
"""Create instance from the currently selected nodes""" | |
def process_context(self, context): | |
selection = cmds.ls(sl=1) | |
if not selection: | |
raise pyblish.api.SelectionError("Select something") | |
instance = context.create_instance(name=selection[0]) | |
for node in selection: | |
instance.add(node) | |
print instance | |
context = pyblish.api.Context() | |
SelectSelected().process_all(context) | |
print context | |
# Result: [pyblish.plugin.Instance('pCube1')] # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment