def invoke(self, context, event=None): label_name = context.scene.labels_regex SearchMark.marked_objects_hide = {} objects = mu.get_non_functional_objects() SearchPanel.marked_objects = [] for obj in objects: is_valid = False try: import fnmatch if fnmatch.fnmatch(obj.name, '*{}*'.format(label_name)): is_valid = True except: if label_name in obj.name: is_valid = True if is_valid: bpy.context.scene.objects.active = bpy.data.objects[obj.name] bpy.data.objects[obj.name].select = True SearchMark.marked_objects_hide[obj.name] = bpy.data.objects[ obj.name].hide bpy.data.objects[obj.name].hide = False bpy.data.objects[ obj.name].active_material = bpy.data.materials[ 'selected_label_Mat'] SearchPanel.marked_objects.append(obj.name) # bpy.data.objects['inflated_'+obj.name].select = True SearchPanel.addon.show_rois() return {"FINISHED"}
def invoke(self, context, event=None): label_name = context.scene.labels_regex SearchMark.marked_objects_select = {} objects = mu.get_non_functional_objects() SearchPanel.marked_objects = [] for obj in objects: SearchFilter.marked_objects_select[obj.name] = obj.select obj.select = label_name in obj.name if label_name in obj.name: SearchPanel.marked_objects.append(obj.name) SearchPanel.addon.show_rois() return {"FINISHED"}
def invoke(self, context, event=None): label_name = context.scene.labels_regex SearchMark.marked_objects_hide = {} objects = mu.get_non_functional_objects() SearchPanel.marked_objects = [] for obj in objects: if label_name in obj.name: bpy.context.scene.objects.active = bpy.data.objects[obj.name] bpy.data.objects[obj.name].select = True SearchMark.marked_objects_hide[obj.name] = bpy.data.objects[obj.name].hide bpy.data.objects[obj.name].hide = False bpy.data.objects[obj.name].active_material = bpy.data.materials['selected_label_Mat'] SearchPanel.marked_objects.append(obj.name) SearchPanel.addon.show_rois() return {"FINISHED"}
def invoke(self, context, event=None): label_name = context.scene.labels_regex SearchMark.marked_objects_select = {} objects = mu.get_non_functional_objects() SearchPanel.marked_objects = [] for obj in objects: SearchFilter.marked_objects_select[obj.name] = obj.select obj.select = label_name in obj.name try: import fnmatch if fnmatch.fnmatch(obj.name, '*{}*'.format(label_name)): SearchPanel.marked_objects.append(obj.name) except: if label_name in obj.name: SearchPanel.marked_objects.append(obj.name) # todo: show rois only if the object is an ROI. Also, move the cursor SearchPanel.addon.show_rois() return {"FINISHED"}
def invoke(self, context, event=None): label_name = context.scene.labels_regex SearchMark.marked_objects_hide = {} objects = mu.get_non_functional_objects() SearchPanel.marked_objects = [] for obj in objects: if label_name in obj.name: bpy.context.scene.objects.active = bpy.data.objects[obj.name] bpy.data.objects[obj.name].select = True SearchMark.marked_objects_hide[obj.name] = bpy.data.objects[ obj.name].hide bpy.data.objects[obj.name].hide = False bpy.data.objects[ obj.name].active_material = bpy.data.materials[ 'selected_label_Mat'] SearchPanel.marked_objects.append(obj.name) SearchPanel.addon.show_rois() return {"FINISHED"}
def invoke(self, context, event=None): label_name = context.scene.labels_regex SearchMark.marked_objects_select = {} objects = mu.get_non_functional_objects() SearchPanel.marked_objects = [] for obj in objects: SearchFilter.marked_objects_select[obj.name] = obj.select obj.select = label_name in obj.name try: import fnmatch if fnmatch.fnmatch(obj.name, '*{}*'.format(label_name)): SearchPanel.marked_objects.append(obj.name) except: if label_name in obj.name: SearchPanel.marked_objects.append(obj.name) if len(SearchPanel.marked_objects) == 0: print('No objects found for "{}"'.format( context.scene.labels_regex)) return # todo: show rois only if the object is an ROI. Also, move the cursor selected_obj = bpy.data.objects[SearchPanel.marked_objects[0]] verts = np.array([vert.co for vert in selected_obj.data.vertices]) center = np.mean(verts, axis=0) if any([mu.obj_is_cortex(o) for o in SearchPanel.marked_objects]): selected_roi = [ o for o in SearchPanel.marked_objects if mu.obj_is_cortex(o) ][0] hemi = mu.get_obj_hemi(selected_roi) center = _addon().where_am_i.pos_to_current_inflation(center, hemis=[hemi]) else: center = mathutils.Vector(center) * mu.get_matrix_world() # if bpy.context.scene.search_plot_contour: # _addon().where_am_i.plot_closest_label_contour(selected_roi, hemi) # bpy.context.scene.cursor_location = tuple(center) _addon().where_am_i.set_cursor_location(center) # _addon().set_cursor_pos() # _addon().set_tkreg_ras(bpy.context.scene.cursor_location * 10, False) if bpy.context.scene.slices_rotate_view_on_click: mu.rotate_view_to_vertice() # if any([mu.obj_is_cortex(o.name) for o in SearchPanel.marked_objects]): # SearchPanel.addon.show_rois() return {"FINISHED"}