def _task_new(self, *args): types = self.core.get("get_parameter_sets")("task").values() one_type = sorted(types, key=lambda item: item["weight"])[0] name = get_non_conflicting_name("Task #%d", [task["name"] for task in self]) new_task = TaskEntity({"type": one_type["name"], "parameters": one_type["parameters"].copy(), "name": name}) self.append(new_task) self.select(new_task)
def add_new(self, new_tp): if isinstance(new_tp, pycam.Toolpath.Toolpath): moves = new_tp.path filters = new_tp.filters else: moves, filters = new_tp name = get_non_conflicting_name("Toolpath #%d", [tp["name"] for tp in self]) attributes = {"visible": True, "name": name} new_tp = ToolpathEntity(toolpath_path=moves, attributes=attributes, toolpath_filters=filters) self.append(new_tp)
def _process_new(self, *args): strategies = self.core.get("get_parameter_sets")("process").values() strategies.sort(key=lambda item: item["weight"]) strategy = strategies[0] name = get_non_conflicting_name("Process #%d", [process["name"] for process in self]) new_process = ProcessEntity({"strategy": strategy["name"], "parameters": strategy["parameters"].copy(), "name": name}) self.append(new_process) self.select(new_process)
def add_model(self, model, name=None, name_template="Model #%d", color=None): model_dict = ModelEntity(model) if not name: name = get_non_conflicting_name(name_template, [m["name"] for m in self]) model_dict["name"] = name if not color: color = self.core.get("color_model") if not color: color = self.FALLBACK_COLOR.copy() model_dict["color"] = color model_dict["visible"] = True self.append(model_dict)
def add_new(self, new_tp): if isinstance(new_tp, pycam.Toolpath.Toolpath): moves = new_tp.path tool = new_tp.tool filters = new_tp.filters else: moves, tool, filters = new_tp name = get_non_conflicting_name("Toolpath #%d", [tp["name"] for tp in self]) attributes = {"visible": True, "name": name} new_tp = ToolpathEntity(toolpath_path=moves, attributes=attributes, toolpath_filters=filters, tool=tool) self.append(new_tp)
def add_model(self, model, name=None, name_template="Model #%d", color=None): model_dict = ModelEntity(model) if not name: name = get_non_conflicting_name(name_template, [model["name"] for model in self]) model_dict["name"] = name if not color: color = self.core.get("color_model") if not color: color = self.FALLBACK_COLOR.copy() model_dict["color"] = color model_dict["visible"] = True self.append(model_dict)
def add_new(self, new_tp, name=None): assert isinstance(new_tp, pycam.Toolpath.Toolpath), \ "Invalid type: %s (%s)" % (type(new_tp), new_tp) moves = new_tp.path tool = new_tp.tool filters = new_tp.filters if name is None: name = get_non_conflicting_name("Toolpath #%d", [tp["name"] for tp in self]) attributes = {"visible": True, "name": name} new_tp = ToolpathEntity(toolpath_path=moves, attributes=attributes, toolpath_filters=filters, tool=tool) self.append(new_tp)
def _bounds_new(self, *args): name = get_non_conflicting_name("Bounds #%d", [bounds["name"] for bounds in self]) new_bounds = BoundsEntity(self.core, name) self.append(new_bounds) self.select(new_bounds)
def get_non_conflicting_name(self, name_template): return get_non_conflicting_name( name_template, [item.get_application_value("name") for item in self.get_all()])
def _bounds_new(self, *args): name = get_non_conflicting_name("Bounds #%d", [bounds["name"] for bounds in self]) new_bounds = BoundsDict(self.core, name) self.append(new_bounds) self.select(new_bounds)