# How to get 3d view grid properties?

I am trying to store the grid scale, but keep getting an error for being in the text editor view.

I have tried

bpy.context.area.type = "VIEW_3D"
print(bpy.context.space_data.grid_scale)


but am getting an attribute error for "SpaceTextEditor" not having a "grid_scale". However, the space does change to the 3d view, so the first line is going through.

Any help is appreciated.

Your code works for me in 2.69, but there might be timing issues (grid_scale accessed but the view has not finished changing).

To get all 3D Views' grid_scale as a list, use:

grid_scales = [area.spaces[0].grid_scale for area in bpy.context.screen.areas if area.type == 'VIEW_3D']