-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
59 lines (44 loc) · 1.54 KB
/
__init__.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
import bpy
from mathutils import Vector
bl_info = {
"name": "Hook Helper",
"description": "点击重置,钩挂物体一起回到'钩挂创建点'",
"author": "AIGODLIKE Community(BlenderCN辣椒, 会飞的键盘侠, 小萌新)",
"version": (1, 0),
"blender": (4, 0, 0),
"location": "Tool Panel",
"support": "COMMUNITY",
"category": "辣椒出品",
}
def HookReset(object, hook):
for m in object.modifiers:
if m.object==hook:
P=Vector([m.center[0],m.center[1],m.center[2]])
hook.location=P
class HookResetOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.hook_reset_lj"
bl_label = "辣椒:钩挂物体校正已启动"
@classmethod
def poll(cls, context):
return context.active_object is not None and len(context.selected_objects)==2
def execute(self, context):
ob=context.active_object
hk=[obj for obj in context.selected_objects if obj != ob]
print(hk)
HookReset(ob, hk[0])
return {'FINISHED'}
def draw(self, context):
layout = self.layout
layout.operator_context = 'EXEC_AREA'
if any([mod.type == 'HOOK' for mod in context.active_object.modifiers]):
layout.separator()
layout.operator(HookResetOperator.bl_idname)
def register():
bpy.utils.register_class(HookResetOperator)
bpy.types.VIEW3D_MT_hook.append(draw)
def unregister():
bpy.utils.unregister_class(HookResetOperator)
bpy.types.VIEW3D_MT_hook.remove(draw)
if __name__ == "__main__":
register()