TclCommandSetActive.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommand
  3. class TclCommandSetActive(TclCommand):
  4. """
  5. Tcl shell command to set an object as active in the GUI.
  6. example:
  7. """
  8. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  9. aliases = ['set_active']
  10. # Dictionary of types from Tcl command, needs to be ordered
  11. arg_names = collections.OrderedDict([
  12. ('name', str),
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  15. option_types = collections.OrderedDict([
  16. ])
  17. # array of mandatory options for current Tcl command: required = {'name','outname'}
  18. required = ['name']
  19. # structured help for current command, args needs to be ordered
  20. help = {
  21. 'main': 'Sets an object as active.',
  22. 'args': collections.OrderedDict([
  23. ('name', 'Name of the Object.'),
  24. ]),
  25. 'examples': []
  26. }
  27. def execute(self, args, unnamed_args):
  28. """
  29. :param args:
  30. :param unnamed_args:
  31. :return:
  32. """
  33. obj_name = args['name']
  34. try:
  35. self.app.collection.set_active(str(obj_name))
  36. except Exception as e:
  37. return "Command failed: %s" % str(e)