TclCommandNewGeometry.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from tclCommands.TclCommand import TclCommandSignaled
  2. import collections
  3. class TclCommandNewGeometry(TclCommandSignaled):
  4. """
  5. Tcl shell command to subtract polygon from the given Geometry object.
  6. """
  7. # array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  8. aliases = ['new_geometry']
  9. description = '%s %s' % ("--", "Creates a new empty Geometry object.")
  10. # Dictionary of types from Tcl command, needs to be ordered.
  11. # For positional arguments
  12. arg_names = collections.OrderedDict([
  13. ('name', str)
  14. ])
  15. # Dictionary of types from Tcl command, needs to be ordered.
  16. # 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 = []
  21. # structured help for current command, args needs to be ordered
  22. help = {
  23. 'main': "Creates a new empty Geometry object.",
  24. 'args': collections.OrderedDict([
  25. ('name', 'New object name.'),
  26. ]),
  27. 'examples': ['new_geometry\n'
  28. 'new_geometry my_new_geo']
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. execute current TCL shell command
  33. :param args: array of known named arguments and options
  34. :param unnamed_args: array of other values which were passed into command
  35. without -somename and we do not have them in known arg_names
  36. :return: None or exception
  37. """
  38. if 'name' in args:
  39. name = args['name']
  40. else:
  41. name = 'new_geo'
  42. self.app.new_object('geometry', str(name), lambda x, y: None, plot=False)