Invalid context [SOLVED]

How can I run “bpy.ops.screen.space_context_cycle” in my addon, it tells me invalid context, when are in the viewport dont work.

Thank you.

This operator is for switching to the next tab in the properties editor, it’s not supposed to work in the 3D viewport.

1 Like

But in blender 2.79 with hotkeys and in 2.8 with hotkeys you can run screen.space_context_cycle even with the mouse on the viewport :S

Not sure what you mean, it doesn’t do anything for me.

I’m trying to make an addon that when I press ctrl + tab in edit mode it changes between edges and faces vertices, but I want that if it’s not in edit mode I keep respecting the blender keys 2.8 and when I do ctrl + tab, I change the workspaces tab.

Then you need bpy.ops.mesh.select_mode, not bpy.ops.screen.space_context_cycle.

Yeah, I got that, the problem is when you’re not in edit mode.

I’ll give you the code fragment summarized:

You can add a poll function to the operator, so it only runs in edit mode:

def poll(cls, context):
    return context.mode == 'EDIT_MESH'
def execute(self, context):
    actions that I do that already work
    return {'FINISHED'}
1 Like

Thanks!!, now works perfectly :smiley:

I am playing with the new 2.8 api, I must update the “oscurart tools”

I’ve a doubt about context in 2.8…

Example: In 2.79 “bpy.ops.object.modifier_move_up(modifier=”")" work fine.

In 2.80 need context… is a temporary problem?

I Tried override the context, but I can’t solve the problem.

RuntimeError: Operator bpy.ops.object.modifier_move_up.poll() Context missing ‘modifier’

Some like this:

If you can send me a lifesaver I will appreciate it