TclCommandNewGeometry.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # Dictionary of types from Tcl command, needs to be ordered.
  10. # For positional arguments
  11. arg_names = collections.OrderedDict([
  12. ('name', str)
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered.
  15. # 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 = []
  20. # structured help for current command, args needs to be ordered
  21. help = {
  22. 'main': "Creates a new empty Geometry object.",
  23. 'args': collections.OrderedDict([
  24. ('name', 'New object name.'),
  25. ]),
  26. 'examples': ['new_geometry\n'
  27. 'new_geometry my_new_geo']
  28. }
  29. def execute(self, args, unnamed_args):
  30. """
  31. execute current TCL shell command
  32. :param args: array of known named arguments and options
  33. :param unnamed_args: array of other values which were passed into command
  34. without -somename and we do not have them in known arg_names
  35. :return: None or exception
  36. """
  37. if 'name' in args:
  38. name = args['name']
  39. else:
  40. name = 'new_geo'
  41. self.app.new_object('geometry', str(name), lambda x, y: None, plot=False)