1
$\begingroup$

I'm trying to learn more about using the info window with Python. Turning it into an addon. I feel like I got pretty close, but it is giving me an error.

import bpy

class cubeMover():

    bpy.ops.transform.translate(value=(0, 2.86946, 0), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True)


def register():
    bpy.utils.register_class(cubeMover)

def unregister():
    bpy.utils.unregister_class(cubeMover)

if __name__ == "__main__":
    register()

When I run the code using just this it runs fine.

import bpy
bpy.ops.transform.translate(value=(0, 2.86946, 0), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True)

But when I try and change it into an addon it doesn't work.

$\endgroup$
1

1 Answer 1

1
$\begingroup$

You should probably define an operator. See Python example files that come with Blender about how to write an operator:

enter image description here

It might be a good idea to change objects location directly instead of using an operator that is for user interaction. You can change the location of the active object by changing bpy.context.object.location values.

$\endgroup$
1
  • $\begingroup$ OK thanks. I'll keep that in mind. So let's say I use the "Operator Simple" default python code they give me. What would the final code look like if I wanted to rotate the cube 60 degrees on the x axis? $\endgroup$
    – GoodNight
    Commented Apr 5, 2019 at 14:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .