def track_selection(self, *_, **__): new_sel = cmds.ls(sl=True, fl=True, l=True) or [] results = [] for item in self.selected: if item in new_sel: results.append(item) for item in new_sel: if not item in results: results.append(item) self.selected = results Logger.debug("selection %s" % self.selected)
def kill(self): if self.Data.get('scriptJob') > 0: cmds.scriptJob(k=self.Data['scriptJob']) self.Data['scriptJob'] = -1 Logger.info('kill scriptJob %s' % self.__class__)
def start(self, **sjFlags): kwargs = {self.ScriptFlag: (self.EventType, self)} kwargs.update(sjFlags) self.Data['scriptJob'] = cmds.scriptJob(**kwargs) Logger.info('start scriptJob %s' % self.__class__)
def start(self, *args, **kwargs): Logger.debug("starting selection watcher") self.watcher = SelectionChanged() self.watcher += self.track_selection self.selected = cmds.ls(sl=True, fl=True, l=True) or [] self.watcher.start()