def selection_changed(self): nodes = self.nodetable.selected_nodes if not self.nodetable.selected_nodes: self.versions.set_nodes_and_cacheversions(None, None) self.comparison.set_node_and_cacheversion(None, None) return workspace = self.workspace_widget.workspace all_cacheversions = list_available_cacheversions(workspace) available_cacheversions = filter_cacheversions_containing_nodes( filter_invisible_nodes_for_manager(cmds.ls(type=DYNAMIC_NODES)), all_cacheversions) connected_cacheversions = filter_connected_cacheversions( nodes, available_cacheversions) if not connected_cacheversions: self.comparison.set_node_and_cacheversion(None, None) self.versions.set_nodes_and_cacheversions(nodes, available_cacheversions) return self.versions.set_nodes_and_cacheversions(nodes, available_cacheversions) if not cacheversion_contains_node(nodes[0], connected_cacheversions[0]): self.comparison.set_node_and_cacheversion(None, None) return self.comparison.set_node_and_cacheversion(nodes[0], connected_cacheversions[0])
def append_cache(self, selection=True): register_time_callback() if self.cacheoptions.verbose is True: add_to_time_callback(time_verbose) workspace = self.workspace_widget.directory if workspace is None: return cmds.warning("no workspace set") set_last_used_workspace(workspace) self.workspace_widget.populate() if selection is True: nodes = self.nodetable.selected_nodes or [] else: nodes = cmds.ls(type=DYNAMIC_NODES) nodes = filter_invisible_nodes_for_manager(nodes) if not nodes: return cmds.warning("no nodes selected") cacheversion = None for node in nodes: cacheversions = filter_connected_cacheversions( [node], list_available_cacheversions(workspace)) if not cacheversions: message = "some nodes doesn't have cache connected to append" return cmds.warning(message) if cacheversion is None: cacheversion = cacheversions[0] if cacheversions[0] != cacheversion: message = "append cache on multiple version is not suppported." return cmds.warning(message) append_to_cacheversion( nodes=nodes, cacheversion=cacheversion, evaluate_every_frame=self.cacheoptions.samples_evaluated, save_every_evaluation=self.cacheoptions.samples_recorded, playblast=self.playblast.record_playblast, playblast_viewport_options=self.playblast.viewport_options) self.nodetable.update_layout() self.selection_changed() unregister_time_callback() clear_time_callback_functions()
def erase_cache(self, selection=True): register_time_callback() if self.cacheoptions.verbose is True: add_to_time_callback(time_verbose) start_frame, end_frame = self.cacheoptions.range workspace = self.workspace_widget.directory if workspace is None: return cmds.warning("no workspace set") set_last_used_workspace(workspace) self.workspace_widget.populate() if selection is True: nodes = self.nodetable.selected_nodes or [] else: nodes = cmds.ls(type=DYNAMIC_NODES) nodes = filter_invisible_nodes_for_manager(nodes) cacheversions = filter_connected_cacheversions( nodes, list_available_cacheversions(workspace)) if not cacheversions or len(cacheversions) > 1: cmds.warning( 'no valid cache version or more than one cacheversion are ' 'connected to the selected dynamic nodes') self.create_cache(selection=selection) return record_in_existing_cacheversion( cacheversion=cacheversions[0], start_frame=start_frame, end_frame=end_frame, nodes=nodes, behavior=self.cacheoptions.behavior, evaluate_every_frame=self.cacheoptions.samples_evaluated, save_every_evaluation=self.cacheoptions.samples_recorded, playblast=self.playblast.record_playblast, playblast_viewport_options=self.playblast.viewport_options) self.nodetable.update_layout() self.selection_changed() unregister_time_callback() clear_time_callback_functions()
from ncachefactory.versioning import list_available_cacheversions DEFAULT_VALUES = { "comment": "", "name": "batch ", "creation_time": 0, "modification_time": 0, "playblasts": [], "end_frame": 120, "nodes": {}, "start_frame": 1 } workspace_to_clean = "" cacheversions = list_available_cacheversions(workspace_to_clean) for cacheversion in cacheversions: for k, v in DEFAULT_VALUES.items(): if cacheversion.infos.get(k) is None: print cacheversion.name, "is out of date and doesn't have", k, "registered, default value set" cacheversion.infos[k] = v cacheversion.save_infos()
def set_workspace(self, workspace): self._workspace = workspace cacheversions = list_available_cacheversions(self._workspace) self.table_model.set_cacheversions(cacheversions)
def _full_update_callback(self, *unused_callbacks_args): self.table_model.set_nodes(filtered_dynamic_nodes()) if not self._workspace: return cacheversions = list_available_cacheversions(self._workspace) self.table_model.set_cacheversions(cacheversions)