I'm trying to change the tile_grid_shape in the UV Editor window located in the UV Editing workspace. The problem is that the only way to do this that I found is bpy.context.... but using context is not an option in my case since the context is actually a different window. If I change the context to be UV Editor it changes the tiles in that window and not in the one in the UV Editing workspace.

This is what I tried with no success:

for area in bpy.data.screens['UV Editing'].areas:
    if area.type == 'IMAGE_EDITOR':
        area.type.uv_editor.tile_grid_shape[0] = 3

In this case I'm getting an error that 'str' object has no attribute 'uv_editor'

I also tried this:

bpy.data.screens['UV Editing'].uv_editor.tile_grid_shape[0] = 3

Still no success though. I'm getting an error that 'screen' object has no attribute 'uv_editor'

I got it from here, but it doesn't work. I guess they changed it and didn't correct it here.

enter image description here

I also know of one other method with context override where you copy the context and do whatever you want in the new one, but the problem with that is that you can't delete the newly created context and when using it in a big batch it makes thousands of context copies and takes a lot of memory that you can't clear unless you restart Blender.

So does anyone have any idea how to do this thing?


1 Answer 1


Is a property of the UV editor space of the Image editor space.

Same deal as How to change View3DOverlay.show_stats?

The property is a member of the UV editor space. https://docs.blender.org/api/current/bpy.types.SpaceUVEditor.html#bpy.types.SpaceUVEditor.tile_grid_shape

following references will see that the UV editor is available from the Image editor


Test in python console.

>>> for i, a in enumerate(C.screen.areas):
...     i, a.type
(3, 'VIEW_3D')
(4, 'CONSOLE')

>>> space = C.screen.areas[2].spaces.active
>>> space
bpy.data.screens['UV Editing']...SpaceImageEditor

>>> space.uv_editor
bpy.data.screens['UV Editing'].uv_editor
# Wrongly represents itself.

>>> type(space.uv_editor)
<class 'bpy.types.SpaceUVEditor'>

>>> space.uv_editor.tile_grid_shape[:]
(1, 1)

>>> space.uv_editor.tile_grid_shape = (2, 1)

Re error area.type is a string (see line above) and has no tile_grid_shape property.

  • $\begingroup$ Thank you, that's very helpful! Is it possible change this line: space = C.screen.areas[2].spaces.active to something that doesn't use indexing. This script is supposed to run on a number of machines and the index number of the IMAGE_EDITOR could be different in some cases of user customization. So instead of referencing the second index I'd like to reference the IMAGE_EDITOR in that workspace $\endgroup$
    – Aleks K.
    Commented Feb 7, 2021 at 14:55
  • $\begingroup$ Use just like in your question code. The index is only used by way of example after enumerating the screen areas. Hence in Q code given area is type desired, area.spaces.active.uv_editor.tile_grid_shape = (3, 1) $\endgroup$
    – batFINGER
    Commented Feb 7, 2021 at 15:02

You must log in to answer this question.

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