Skip to content

Instantly share code, notes, and snippets.

@mottosso
Created October 4, 2014 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mottosso/2e3ac775bdf01d5dd047 to your computer and use it in GitHub Desktop.
Save mottosso/2e3ac775bdf01d5dd047 to your computer and use it in GitHub Desktop.
Select Selected - A Pyblish plug-in for Autodesk Maya
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