-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_x_poll.py
More file actions
54 lines (37 loc) · 1.3 KB
/
Copy pathmove_x_poll.py
File metadata and controls
54 lines (37 loc) · 1.3 KB
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
# SPDX-FileCopyrightText: © 2016 Michel Anders (varkenvarken) & contributors
#
# SPDX-License-Identifier: GPL-2.0-or-later
bl_info = {
"name": "Simple Move X Operator",
"author": "Your Name",
"version": (0, 0, 3),
"blender": (5, 0, 0),
"location": "Object > Move X",
"description": "Move the active object along the X axis",
"category": "Object",
}
from bpy.types import Operator
class OBJECT_OT_move_x(Operator):
bl_idname = "object.move_x"
bl_label = "Move X"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
"""Move the active object by 1 unit along the x-axis"""
context.active_object.location.x += 1
return {"FINISHED"}
@classmethod
def poll(cls, context):
"""Ensure we have an active object and that we are in object mode"""
return context.active_object is not None and context.mode == "OBJECT"
from bpy.utils import register_class, unregister_class
from bpy.types import VIEW3D_MT_object
def menu_func(self, context):
self.layout.operator(OBJECT_OT_move_x.bl_idname)
def register():
register_class(OBJECT_OT_move_x)
VIEW3D_MT_object.append(menu_func)
def unregister():
VIEW3D_MT_object.remove(menu_func)
unregister_class(OBJECT_OT_move_x)
if __name__ == "__main__":
register()