Created
October 21, 2015 16:07
-
-
Save mattcox/1ffe6ab52babe2813fdd to your computer and use it in GitHub Desktop.
A pointless command that demonstrates how to use a notifier without arguments
This file contains hidden or 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
#!/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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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