TclCommandSkew.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommand
  3. class TclCommandSkew(TclCommand):
  4. """
  5. Tcl shell command to skew the object by a an angle over X axis and an angle over Y axes.
  6. example:
  7. skew my_geometry 10.2 3.5
  8. """
  9. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  10. aliases = ['skew']
  11. # Dictionary of types from Tcl command, needs to be ordered
  12. arg_names = collections.OrderedDict([
  13. ('name', str),
  14. ('angle_x', float),
  15. ('angle_y', float)
  16. ])
  17. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  18. option_types = collections.OrderedDict([
  19. ])
  20. # array of mandatory options for current Tcl command: required = {'name','outname'}
  21. required = ['name', 'angle_x', 'angle_y']
  22. # structured help for current command, args needs to be ordered
  23. help = {
  24. 'main': "Shear/Skew an object by angles along x and y dimensions.",
  25. 'args': collections.OrderedDict([
  26. ('name', 'Name of the object to skew.'),
  27. ('angle_x', 'Angle in degrees by which to skew on the X axis.'),
  28. ('angle_y', 'Angle in degrees by which to skew on the Y axis.')
  29. ]),
  30. 'examples': ['skew my_geometry 10.2 3.5']
  31. }
  32. def execute(self, args, unnamed_args):
  33. """
  34. :param args:
  35. :param unnamed_args:
  36. :return:
  37. """
  38. name = args['name']
  39. angle_x = args['angle_x']
  40. angle_y = args['angle_y']
  41. self.app.collection.get_by_name(name).skew(angle_x, angle_y)