Skip to content

Instantly share code, notes, and snippets.

@mattcox
Created October 21, 2015 16:07
Show Gist options
  • Save mattcox/1ffe6ab52babe2813fdd to your computer and use it in GitHub Desktop.
Save mattcox/1ffe6ab52babe2813fdd to your computer and use it in GitHub Desktop.
A pointless command that demonstrates how to use a notifier without arguments
#!/usr/bin/env python
import lx
import lxu.command
import modo
class Command (lxu.command.BasicCommand):
def __init__ (self):
lxu.command.BasicCommand.__init__ (self)
self.not_svc = lx.service.NotifySys ()
self.notifier = lx.object.Notifier ()
def basic_Enable (self, msg):
selected = modo.current ().selectedByType (lx.symbol.sITYPE_MESH)
return len (selected) > 0
def cmd_Flags (self):
return 0
def basic_Execute (self, msg, flags):
selected = modo.current ().selectedByType (lx.symbol.sITYPE_MESH)
for item in selected:
lx.out (item.name)
def cmd_NotifyAddClient (self, argument, object):
self.notifier = self.not_svc.Spawn ("select.event", "item +d")
self.notifier.AddClient (object)
def cmd_NotifyRemoveClient (self, object):
self.notifier.RemoveClient (object)
lx.bless (Command, "mesh.printName")
@ivogrig
Copy link

ivogrig commented Oct 26, 2015

On a different note: there is a shortcut for common item types, so
selected = modo.current ().selectedByType (lx.symbol.sITYPE_MESH)

can be substituted with
selected = modo.Scene().meshes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment