-
Notifications
You must be signed in to change notification settings - Fork 0
/
Select_Linked_multi_v2.py
98 lines (78 loc) · 3.87 KB
/
Select_Linked_multi_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# Add-on info
bl_info = {
"name": "Object Data (multi)",
"author": "APEC",
"version": (0, 0, 2),
"blender": (2, 93, 0),
"location": "Select - Select Linked (multi)",
"description": "Select Linked - Object Data for multiple selected objects",
"doc_url": "",
"tracker_url": "",
"category": "Object" # Menu, Object, Collection, etc.
}
import bpy
###########################################################################################
################################## Operators ########################################
###########################################################################################
class OBJECT_OT_select_linked_multi(bpy.types.Operator):
bl_idname = "object.select_linked_multi"
bl_label = "Object Data (multi)"
#bl_description = "Select Linked (multi)"
def execute(self, context):
active_object = bpy.context.view_layer.objects.active
for ob in context.selected_objects:
bpy.context.view_layer.objects.active = ob
bpy.ops.object.select_linked(extend=True, type='OBDATA')
bpy.context.view_layer.objects.active = active_object
return {'FINISHED'}
###########################################################################################
##################################### UI ############################################
###########################################################################################
class VIEW3D_MT_select_linked_multi(bpy.types.Menu):
bl_label = "Select Linked (multi)"
bl_idname = "VIEW3D_MT_select_linked_multi"
def draw(self, context):
layout = self.layout
layout.operator("object.select_linked_multi")
def add_menu(self, context):
layout = self.layout
#layout.separator()
layout.menu(VIEW3D_MT_select_linked_multi.bl_idname)
def add_menu_single(self, context):
self.layout.operator("object.select_linked_multi")
###########################################################################################
##################################### Register ############################################
###########################################################################################
def register():
bpy.utils.register_class(OBJECT_OT_select_linked_multi)
bpy.utils.register_class(VIEW3D_MT_select_linked_multi)
# to appear at the top of menu list
#bpy.types.VIEW3D_MT_select_object.prepend(add_menu)
#bpy.types.VIEW3D_MT_select_object.prepend(add_menu_single)
# to appear at the bottom of menu list
bpy.types.VIEW3D_MT_select_object.append(add_menu)
#bpy.types.VIEW3D_MT_select_object.append(add_menu_single)
def unregister():
bpy.utils.unregister_class(OBJECT_OT_select_linked_multi)
bpy.utils.unregister_class(VIEW3D_MT_select_linked_multi)
bpy.types.VIEW3D_MT_select_object.remove(add_menu)
#bpy.types.VIEW3D_MT_select_object.remove(add_menu_single)
if __name__ == "__main__":
register()