TclCommandScale.py 1.4 KB

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