Store UV/Image Editor area state (zoom factor, position etc.)?


Is there a way to save a ‘state’ of area so it can be restored any time?
I have a script that creates/collapses UV Editor area on the right side of 3D View area, so it would be nice to not loose position ans zoom factor.

It changes when adding texture depend on it resolution… also annoying.

But if you split window and use Num0 to toggle maximize area, it will save zoom factor.
For scripting would be useful to know how to store parameters.

Start looking at this just in case you follow the same approach.

Thanks for link and sorry for late answer.
It seems that 3D View area has a lot more possibilities than 2D View, so I don’t see how it would work…
I managed to store some area properties in class, but it is the easy one.
Still looking for solution, however it look like there is no way to do so through python.

Yeah the problem is that it’s these values are read-only.

import bpy

areas = bpy.context.screen.areas
area_types = [a.type for a in areas]
image_area = [a for a in areas if a.type == 'IMAGE_EDITOR']

if len(image_area)>0:
    image_area = image_area[0]
    x,y = image_area.x, image_area.y
    # bpy.types.Area
    # print(type(image_area))

    # bpy.types.SpaceImageEditor
    editor = image_area.spaces[0]
    zoom = editor.zoom[0] # zoom is 1D

Perhaps you could attempt to write a C operator that will set the view with (x,y,zoom).