I compiled Blender as python module to be able to do unit testing of a plugin I'm working on. The issue is that bpy.context.area and other context values do not seem to populate so I can't run operators that require a specific area (like bpy.ops.screen.region_quadviews()).

How do I set the active area and region in Blender?

  • 1
    $\begingroup$ Related $\endgroup$
    – batFINGER
    Sep 28, 2017 at 5:01
  • $\begingroup$ If your running in headless mode then there are no screen regions to work with. Maybe setup two testing steps, one without gui and one with. $\endgroup$
    – sambler
    Sep 28, 2017 at 8:23
  • $\begingroup$ @sambler The regions exist, you can explore them in bpy.data.screen.areas and further. There's just no way to set any sort of active one. I've tried using cursor_warp to place the "cursor" over them, as well as some other ones that talk about "cycling the context" but nothing seems to work. There might be a new function in 2.79 that handles it that I'm rebuilding to test out $\endgroup$
    – Cobertos
    Sep 29, 2017 at 2:56
  • $\begingroup$ As has been quoted from a blender developer "when in background mode there is no window or opengl context" for any screen region to exist in, that is what leads to no screen regions being available, even though the properties exist, that doesn't mean there is any valid data that can be used. $\endgroup$
    – sambler
    Sep 29, 2017 at 5:47
  • $\begingroup$ Hmm, I think that I might just be able to get away with faking a context and passing it to my class like you've provided in the link. I think that's the only way to go for now $\endgroup$
    – Cobertos
    Sep 29, 2017 at 6:00


You must log in to answer this question.

Browse other questions tagged .