TclCommandScale.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommand
  3. class TclCommandScale(TclCommand):
  4. """
  5. Tcl shell command to resizes the object by a factor.
  6. example:
  7. scale my_geometry 4.2
  8. """
  9. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  10. aliases = ['scale']
  11. # Dictionary of types from Tcl command, needs to be ordered
  12. arg_names = collections.OrderedDict([
  13. ('name', str),
  14. ('factor', float)
  15. ])
  16. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  17. option_types = collections.OrderedDict([
  18. ])
  19. # array of mandatory options for current Tcl command: required = {'name','outname'}
  20. required = ['name', 'factor']
  21. # structured help for current command, args needs to be ordered
  22. help = {
  23. 'main': "Resizes the object by a factor.",
  24. 'args': collections.OrderedDict([
  25. ('name', 'Name of the object to resize.'),
  26. ('factor', 'Fraction by which to scale.')
  27. ]),
  28. 'examples': ['scale my_geometry 4.2']
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. :param args:
  33. :param unnamed_args:
  34. :return:
  35. """
  36. name = args['name']
  37. factor = args['factor']
  38. self.app.collection.get_by_name(name).scale(factor)