TclCommandPlotObjects.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 tclCommands.TclCommand import TclCommand
  8. import collections
  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. description = '%s %s' % ("--", "Plot a specified list of objects in GUI.")
  18. # Dictionary of types from Tcl command, needs to be ordered
  19. arg_names = collections.OrderedDict([
  20. ('names', str)
  21. ])
  22. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  23. option_types = collections.OrderedDict([
  24. ])
  25. # array of mandatory options for current Tcl command: required = {'name','outname'}
  26. required = ['names']
  27. # structured help for current command, args needs to be ordered
  28. help = {
  29. 'main': "Plot a specified list of objects in GUI.",
  30. 'args': collections.OrderedDict([
  31. ('names', "A list of object names to be plotted separated by comma. Required.\n"
  32. "WARNING: no spaces are allowed. If unsure enclose the entire list with quotes.")
  33. ]),
  34. 'examples': ["plot_objects gerber_obj.GRB,excellon_obj.DRL"]
  35. }
  36. def execute(self, args, unnamed_args):
  37. """
  38. :param args:
  39. :param unnamed_args:
  40. :return:
  41. """
  42. if self.app.cmd_line_headless != 1:
  43. names = [x.strip() for x in args['names'].split(",") if x != '']
  44. objs = []
  45. for name in names:
  46. objs.append(self.app.collection.get_by_name(name))
  47. for obj in objs:
  48. obj.plot()