1
$\begingroup$
import bpy
for window in bpy.context.window_manager.windows:
    screen = window.screen

    for area in screen.areas:
        if area.type == 'VIEW_3D':
            override = {'window': window, 'screen': screen, 'area': area}
            bpy.ops.screen.screen_full_area(override)
            break
    

I'm learning blender python with its documentation. The code is one of the example code from the tutorial. What I don't understand is, the variable screen doesn't belong to iterable module called bpy.context.window_manager.windows. If everything comes together, shouldn't this be bpy.context.window_manager.windows.window.screen because variable window is a part of the module?

>>> bpy.context.window_manager.windows.
                                       as_bytes(
                                       data
                                       find(
                                       foreach_get(
                                       foreach_set(
                                       get(
                                       id_data
                                       items(
                                       keys(
                                       path_from_id(
                                       rna_type(
                                       update(
                                       values(

See, there's no module called window. All I can see in the console panel is bunch of built-in functions.

    for area in screen.areas:
        if area.type == 'VIEW_3D':
            override = {'window': window, 'screen': screen, 'area': area}
            bpy.ops.screen.screen_full_area(override)
            break

This one is same. I can't find screen.areas in area module. screen.areas is iterable and loop is ongoing so it should say ...screen.areas.area.type yet there's nothing in it. (even bpy.ops.screen has no area.type.)

What is going on in this code? How can I see visually where the modules are located in my console tab?

$\endgroup$
2
  • 2
    $\begingroup$ A blender collection is a mapping that behaves like a dictionary and a list. In this case, a particular window is window = windows[0] not windows.window This is the case for all collections. Also a member of a collection is not necessarily a module. eg a list called ints = [1, 2, 3] can be iterated for i in ints: there is no expectation that can use ints.i. $\endgroup$
    – batFINGER
    Oct 17, 2021 at 6:30
  • $\begingroup$ @batFINGER Can I understand this is same concept looping nested array in Javascript? o.o $\endgroup$ Oct 17, 2021 at 6:40

1 Answer 1

1
$\begingroup$

What you are missing is that bpy.context.window_manager.windows is an iterable:

>>> type(bpy.context.window_manager.windows)
<class 'bpy_prop_collection'>

In order to see a window, you must choose a member:

>>> type(bpy.context.window_manager.windows[0])
<class 'bpy.types.Window'>

Or you can chain together something like this since screen.areas is also an iterable:

bpy.context.window_manager.windows[0].screen.areas[0].type
$\endgroup$
1
  • $\begingroup$ Thanks for details. I was literally chocking myself lol $\endgroup$ Oct 17, 2021 at 6:38

You must log in to answer this question.

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