As the title suggests, I have a simple code (part of a bit larger structure) that’s supposed to minimize the already maximized area and then maximize that exact area again. Keep in mind that I’m not using something like ‘area.ui_type’ as an ID because I can have multiple areas of the same type, I need unique ID’s for my purposes. If you want to reproduce the code, just maximize the ‘TEXT_EDITOR’ area and run the code.
import bpy
if bpy.context.screen.show_fullscreen:
id = bpy.context.area.regions[0].as_pointer()
bpy.ops.screen.screen_full_area(use_hide_panels=False)
for area in bpy.context.screen.areas:
if area.regions[0].as_pointer() == id:
with (bpy.context.temp_override(area=area)):
bpy.ops.screen.screen_full_area(use_hide_panels=False)
EDIT:
The problem might be deep-rooted and file specific. I created a new .blend file, tested the whole code and it works flawlessly and the same goes for my other project files. It’s just this one file that has the problem where I originally started writing code. Unfortunately, I can’t share the files as it’s under NDA and I can’t reproduce the problem in other files since I have no idea what’s causing it. I’ve isolated the issue and it’s bpy.context.screen.screen_full_area() causing the crash, it’s only crashing when the text editor or python console is already maximized and the code line is executed.
Turns out it was a linked scene from another file that was causing the crash. Thankfully it was something that was completely unnecessary and was accidentally linked, its removal fixed the problem.
1 Like
Hello, I can offer unwanted advice you’re free to disregard but I would avoid overloading builtins like id
in the global namespace. If you import
this module this might have unintended consequences and make you very upset when you finally discover why.
Cheers
2 Likes
Hi there. Yeah, that’s actually good to know and I’m thankful that you’ve broadened my horizons. I’ll definitely change the code in order to avoid unwanted behaviour in the future. Thanks!
Edit:
You seem pretty knowledgeable, do you by any chance know what would be the best or only way of filtering a pointer-property search by scene. Using prop_search
with search_data
set to the desired scene (if that’s even the proper way of using that argument, my guess would be that using that argument we delimit what type of object we can search for and not where) or by following this article by B3D and modifying it to one’s specific need?
Sure, at the top of my head it should be something like that :
import bpy
class HelloWorldPanel(bpy.types.Panel):
bl_label = "Hello World Panel"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
def draw(self, context):
self.layout.prop(context.scene, 'my_scene', text='')
def filter(self, scene):
return scene.name.startswith("My Specific Scene Prefix") # or whatever
def register():
bpy.utils.register_class(HelloWorldPanel)
bpy.types.Scene.my_scene = bpy.props.PointerProperty(
type=bpy.types.Scene,
poll=filter,
)
if __name__ == "__main__":
register()
1 Like
Thank you so much, but I’ve already solved it in a pretty much the same way.