Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

July 10, 2011

Areas

if this is a short post, come back later. or next week. when i have more to write about it.
>>> for area in bpy.context.window.screen.areas: print(area.type)
...
INFO
PROPERTIES
OUTLINER
VIEW_3D
TEXT_EDITOR
CONSOLE

>>> bpy.context.window.screen.areas[3].regions[2].type
'TOOL_PROPS'
it is possible to query regions in that area (header, toolshelves..etc)
>>>bpy.context.area.regions[0].type
...'Header'


# good
bpy.context.area.type = 'GRAPH_EDITOR'

# bad, will crash blender until fixed
bpy.context = 'GRAPH_EDITOR'

4 comments:

  1. >>> bpy.context.screen.areas[0].type
    'INFO'

    >>> bpy.context.screen.areas[1].type
    'PROPERTIES'

    >>> bpy.context.screen.areas[2].type
    'TIMELINE'

    >>> bpy.context.screen.areas[3].type
    'OUTLINER'

    >>> bpy.context.screen.areas[4].type
    'CONSOLE'

    >>> bpy.context.screen.areas[5].type
    'USER_PREFERENCES'

    >>> bpy.context.screen.areas[6].type
    'VIEW_3D'

    ReplyDelete
  2. >>> bpy.context.screen.areas[6].regions[0].type
    'HEADER'

    >>> bpy.context.screen.areas[6].regions[1].type
    'TOOLS'

    >>> bpy.context.screen.areas[6].regions[2].type
    'TOOL_PROPS'

    >>> bpy.context.screen.areas[6].regions[3].type
    'UI'

    >>> bpy.context.screen.areas[6].regions[4].type
    'WINDOW'

    ReplyDelete
  3. When starting a blender file from the command line eg:
    blender car.blend -P main.py

    bpy.context.area.type = "TIMELINE" ..etc always give errors:
    AttributeError: 'NoneType' object has no attribute 'type'

    How can I fix this?

    Thanks!

    ReplyDelete
    Replies
    1. If you are forcing the context.area.type because you use certain a bpy.ops that require "TIMELINE" as context, you might be able to rewrite the script to avoid using bpy.ops. In the keyword section to the right have a look at "scripted keyframe" for example on how/why to avoid using bpy.ops.

      Failing that consider posting a link to the script you are using (use pastbin.com, don't paste the entire script into the comment section here)

      Delete

Please use Blender.StackExchange.com for python scripting questions unrelated to this post.