def execute(self, context): ng = bpy.data.node_groups.get(self.node_group) if ng: ng.unfreeze(hard=True) build_update_list(ng) process_tree(ng) return {'FINISHED'}
def execute(self, context): sv_ngs = filter(lambda ng:ng.bl_idname == 'SverchCustomTreeType', bpy.data.node_groups) for ng in sv_ngs: ng.unfreeze(hard=True) build_update_list() process_tree() return {'FINISHED'}
def execute(self, context): try: bpy.context.window.cursor_set("WAIT") sv_ngs = filter(lambda ng: ng.bl_idname == 'SverchCustomTreeType', bpy.data.node_groups) for ng in sv_ngs: ng.unfreeze(hard=True) build_update_list() process_tree() finally: bpy.context.window.cursor_set("DEFAULT") return {'FINISHED'}
def sv_update(self): """ the method checks if anything changed inside the normal tree or monad and update them if necessary """ self.sv_links.create_new_links(self) if self.sv_links.links_have_changed(self): self.has_changed = True build_update_list(self) process_from_nodes(self.sv_links.get_nodes(self)) self.sv_links.store_links_cache(self) else: process_from_nodes(self.get_groups())
def execute(self, context): try: bpy.context.window.cursor_set("WAIT") ng = context.space_data.node_tree if ng: build_update_list(ng) process_tree(ng) except: pass finally: bpy.context.window.cursor_set("DEFAULT") return {'FINISHED'}
def import_into_tree(self, tree: SverchCustomTree, print_log: bool = True): """Import json structure into given tree and update it""" if self.structure_version < 0.1001: root_tree_builder = TreeImporter01(tree, self._structure, self._fails_log) root_tree_builder.import_tree() else: importer = FileStruct(logger=self._fails_log, struct=self._structure) importer.build_into_tree(tree) if print_log: self._fails_log.report_log_result() # Update tree build_update_list(tree) process_tree(tree)
def execute(self, context): try: bpy.context.window.cursor_set("WAIT") ng = context.space_data.node_tree if ng: try: prev_process_state = ng.sv_process ng.sv_process = True ng.unfreeze(hard=True) build_update_list(ng) process_tree(ng) finally: ng.sv_process = prev_process_state except: pass finally: bpy.context.window.cursor_set("DEFAULT") return {'FINISHED'}
def create_dict_of_tree(ng, skip_set={}, selected=False, identified_node=None, save_defaults = False): nodes = ng.nodes layout_dict = {} nodes_dict = {} groups_dict = {} if not skip_set: skip_set = {'Sv3DviewPropsNode'} if selected: nodes = list(filter(lambda n: n.select, nodes)) if identified_node: # this mode will import one node only. nodes = [identified_node] # get nodes and params for node in nodes: if node.bl_idname in skip_set: continue node_dict = {} node_items = {} node_enums = find_enumerators(node) IsMonadInstanceNode = (node.bl_idname.startswith('SvGroupNodeMonad')) if save_defaults: node_props = get_node_annotations(node) else: node_props = node.items() for k, v in node_props: display_introspection_info(node, k, v) if can_skip_property(node, k): continue elif has_state_switch_protection(node, k): continue handle_old_groupnode(node, k, v, groups_dict, create_dict_of_tree) if isinstance(v, (float, int, str)): node_items[k] = v elif node.bl_idname in {'ScalarMathNode', 'SvLogicNode'} and k == 'prop_types': node_items[k] = getattr(node, k)[:] continue else: ann = node.bl_rna.__annotations__ # this will only ever encounter pointerproperties that are interactive with # by the user, or they happen to be visible in the UI by defailt. arguably # we should be iterating over `node_props from get_node_annotations(node)` if k in ann: prop_type, prop_details = ann[k] if prop_type == bpy.props.PointerProperty: info(f"skipping {node.name}.{k} (a PointerProperty)") continue node_items[k] = v[:] handle_enum_property(node, k, v, node_items, node_enums) if IsMonadInstanceNode and node.monad: pack_monad(node, node_items, groups_dict, create_dict_of_tree) if hasattr(node, "storage_get_data"): node.storage_get_data(node_dict) node_dict['params'] = node_items collect_custom_socket_properties(node, node_dict) # if node.bl_idname == 'NodeFrame': # frame_props = 'shrink', 'use_custom_color', 'label_size' # node_dict['params'].update({fpv: getattr(node, fpv) for fpv in frame_props}) if IsMonadInstanceNode: node_dict['bl_idname'] = 'SvMonadGenericNode' # these are indeed stored. as ints. which is fine. # must also store (.vectorize, bool) (.loop_me, bool) (.loops, int) else: node_dict['bl_idname'] = node.bl_idname if node.bl_idname in {'SvGroupInputsNodeExp', 'SvGroupOutputsNodeExp'}: node_dict[node.node_kind] = node.stash() get_superficial_props(node_dict, node) nodes_dict[node.name] = node_dict # ------------------- layout_dict['nodes'] = nodes_dict layout_dict['groups'] = groups_dict # ''' get connections ''' # links = (compile_socket(l) for l in ng.links) # connections_dict = {idx: link for idx, link in enumerate(links)} # layout_dict['connections'] = connections_dict ''' get framed nodes ''' framed_nodes = {} for node in nodes: if node.bl_idname in skip_set: continue if node.parent: if selected and node.parent.select: framed_nodes[node.name] = node.parent.name elif not selected: framed_nodes[node.name] = node.parent.name layout_dict['framed_nodes'] = framed_nodes ''' get update list (cache, order to link) ''' # try/except for now, node tree links might be invalid # among other things. auto rebuild on F8 try: build_update_list(ng) links_out = [] for name in chain(*get_update_lists(ng)[0]): for socket in ng.nodes[name].inputs: if selected and not ng.nodes[name].select: continue if socket.links: link = socket.links[0] if selected and not link.from_node.select: continue links_out.append(compile_socket(link)) layout_dict['update_lists'] = links_out except Exception as err: exception(err) error('no update lists found or other error!') error(' - trigger an update and retry') return layout_dict['export_version'] = _EXPORTER_REVISION_ return layout_dict
def build_update_list(self): build_update_list(self)
def build_update_list(self): build_update_list(self)