r/blenderpython • • Mar 06 '20

how to delete transform_orientation

I crreated a temporary transform orientation:

bpy.ops.transform.create_orientation(name='tmp')

but calling

bpy.ops.transform.delete_orientation()

doesn't work:

File "C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\modules\bpy\ops.py", line 199, in call ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)

RuntimeError: Operator bpy.ops.transform.delete_orientation.poll() failed, context is incorrect

How can I delete the new transform_orientation?

1 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/dustypacer Mar 07 '20

yeah, they change a lot, but if you're decent with python you can figure it out through the blender console. Use the built-ins dir() and local() to examine the packages and modules in bpy.* You'll find a lot of stuff changes names far more frequently than other projects.

The context is important in scipt vs add on, because an add-on is almost always in the correct context. You right click and add a Suzanne in View3D, the add-on only appears in View3D, so it can assume the context has View3D as the active viewport. Whereas with a script, you can try to run it, while in the script editor, and the context does not have a View3D to draw to, so it needs to find the correct context to do the work in.

Anything in the bpy* packages you're using to remote control Blender, anything you're writing in Python outside of those is the actual programming. You can build some complex programs, but the more interacting with Blender itself the more messy it gets, you ideally want to generate your mesh, or your camera moves, or whatever, and just deal with a few bpy functions to get it into the project