Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_operators/wm.py
| Show First 20 Lines • Show All 2,512 Lines • ▼ Show 20 Lines | data_type: EnumProperty( | ||||
| ('LIGHT', "Light", ""), | ('LIGHT', "Light", ""), | ||||
| ('LIGHT_PROBE', "Light Probes", ""), | ('LIGHT_PROBE', "Light Probes", ""), | ||||
| ('CAMERA', "Cameras", ""), | ('CAMERA', "Cameras", ""), | ||||
| ('SPEAKER', "Speakers", ""), | ('SPEAKER', "Speakers", ""), | ||||
| None, | None, | ||||
| ('BONE', "Bones", ""), | ('BONE', "Bones", ""), | ||||
| ('NODE', "Nodes", ""), | ('NODE', "Nodes", ""), | ||||
| ('SEQUENCE_STRIP', "Sequence Strips", ""), | ('SEQUENCE_STRIP', "Sequence Strips", ""), | ||||
| ('ACTION_CLIP', "Action Clips", ""), | |||||
| ), | ), | ||||
| description="Type of data to rename", | description="Type of data to rename", | ||||
| ) | ) | ||||
| data_source: EnumProperty( | data_source: EnumProperty( | ||||
| name="Source", | name="Source", | ||||
| items=( | items=( | ||||
| ('SELECT', "Selected", ""), | ('SELECT', "Selected", ""), | ||||
| ▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | def _data_from_context(cls, context, data_type, only_selected, *, check_context=False): | ||||
| if (id := slot.material) is not None and id.library is None | if (id := slot.material) is not None and id.library is None | ||||
| )) | )) | ||||
| ) | ) | ||||
| if only_selected else | if only_selected else | ||||
| [id for id in bpy.data.materials if id.library is None], | [id for id in bpy.data.materials if id.library is None], | ||||
| "name", | "name", | ||||
| iface_("Material(s)"), | iface_("Material(s)"), | ||||
| ) | ) | ||||
| elif data_type == "ACTION_CLIP": | |||||
| data = ( | |||||
| ( | |||||
| # Outliner. | |||||
| tuple(set( | |||||
campbellbarton: The action from the object's data isn't likely what users will want, suggest to return actions… | |||||
| action for id in context.selected_ids | |||||
| if (((animation_data := id.animation_data) is not None) and | |||||
| ((action := animation_data.action) is not None) and | |||||
| (action.library is None)) | |||||
| )) | |||||
| if space_type == 'OUTLINER' else | |||||
| # 3D View (default). | |||||
| tuple(set( | |||||
| action for ob in context.selected_objects | |||||
| if (((animation_data := ob.animation_data) is not None) and | |||||
| ((action := animation_data.action) is not None) and | |||||
| (action.library is None)) | |||||
| )) | |||||
| ) | |||||
| if only_selected else | |||||
| [id for id in bpy.data.actions if id.library is None], | |||||
Done Inline ActionsPrefer to keep literal comparisons first, before the data_type in object_data_type_attrs_map.keys() check. campbellbarton: Prefer to keep literal comparisons first, before the `data_type in object_data_type_attrs_map. | |||||
| "name", | |||||
| iface_("Action(s)"), | |||||
| ) | |||||
| elif data_type in object_data_type_attrs_map.keys(): | elif data_type in object_data_type_attrs_map.keys(): | ||||
Done Inline ActionsObject ID's should have special treatment in the outliner. Other ID's can contain animation data (scenes, cameras for e.g.). campbellbarton: Object ID's should have special treatment in the outliner. Other ID's can contain animation… | |||||
Done Inline ActionsCorrection: Object ID's should not need to have have special treatment in the outliner in the case of actions. Other ID's can contain animation data (scenes, cameras for e.g.). campbellbarton: Correction:
//Object ID's should not need to have have special treatment in the outliner in… | |||||
| attr, descr, ty = object_data_type_attrs_map[data_type] | attr, descr, ty = object_data_type_attrs_map[data_type] | ||||
| data = ( | data = ( | ||||
| ( | ( | ||||
| # Outliner. | # Outliner. | ||||
| cls._selected_ids_from_outliner_by_type_for_object_data(context, ty) | cls._selected_ids_from_outliner_by_type_for_object_data(context, ty) | ||||
| if space_type == 'OUTLINER' else | if space_type == 'OUTLINER' else | ||||
| # 3D View (default). | # 3D View (default). | ||||
| tuple(set( | tuple(set( | ||||
| ▲ Show 20 Lines • Show All 524 Lines • Show Last 20 Lines | |||||
The action from the object's data isn't likely what users will want, suggest to return actions from selected ID's, e.g.
tuple(set( action for id in context.selected_ids if (animation_data := id.animation_data) is not None if (action := animation_data.action) is not None ))