TclCommandPlotObjects.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # File Author: Marius Adrian Stanciu (c) #
  4. # Date: 8/17/2019 #
  5. # MIT Licence #
  6. # ##########################################################
  7. from ObjectCollection import *
  8. from tclCommands.TclCommand import TclCommand
  9. class TclCommandPlotObjects(TclCommand):
  10. """
  11. Tcl shell command to update the plot on the user interface.
  12. example:
  13. plot
  14. """
  15. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  16. aliases = ['plot_objects']
  17. # Dictionary of types from Tcl command, needs to be ordered
  18. arg_names = collections.OrderedDict([
  19. ('names', str)
  20. ])
  21. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  22. option_types = collections.OrderedDict([
  23. ])
  24. # array of mandatory options for current Tcl command: required = {'name','outname'}
  25. required = []
  26. # structured help for current command, args needs to be ordered
  27. help = {
  28. 'main': "Plot a list of objects.",
  29. 'args': collections.OrderedDict([
  30. ('names', "UA list of object names to be plotted.")
  31. ]),
  32. 'examples': ["plot_objects"]
  33. }
  34. def execute(self, args, unnamed_args):
  35. """
  36. :param args:
  37. :param unnamed_args:
  38. :return:
  39. """
  40. if self.app.cmd_line_headless != 1:
  41. names = [x.strip() for x in args['names'].split(",")]
  42. objs = []
  43. for name in names:
  44. objs.append(self.app.collection.get_by_name(name))
  45. for obj in objs:
  46. obj.plot()