tool.Blender.update_all_viewports

This commit is contained in:
Andrej730
2026-03-10 11:32:57 +05:00
parent 15ea092ac4
commit 578caaf2cd
5 changed files with 14 additions and 19 deletions
@@ -457,9 +457,7 @@ class HideClash(bpy.types.Operator):
def execute(self, context): def execute(self, context):
ClashDecorator.uninstall() ClashDecorator.uninstall()
for area in context.screen.areas: tool.Blender.update_all_viewports(context)
if area.type == "VIEW_3D":
area.tag_redraw()
return {"FINISHED"} return {"FINISHED"}
@@ -1243,9 +1243,7 @@ class SnapManager:
@staticmethod @staticmethod
def _redraw_viewport() -> None: def _redraw_viewport() -> None:
"""Force 3D viewport redraw.""" """Force 3D viewport redraw."""
for area in bpy.context.screen.areas: tool.Blender.update_all_viewports()
if area.type == "VIEW_3D":
area.tag_redraw()
def build_snap_cache( def build_snap_cache(
self, context: bpy.types.Context, active_obj: bpy.types.Object, include_active: bool = False self, context: bpy.types.Context, active_obj: bpy.types.Object, include_active: bool = False
@@ -2699,10 +2699,7 @@ class CreateClippingPlane(bpy.types.Operator):
self.report({"INFO"}, "Maximum of six clipping planes allowed.") self.report({"INFO"}, "Maximum of six clipping planes allowed.")
return {"FINISHED"} return {"FINISHED"}
assert context.screen tool.Blender.update_all_viewports(context)
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
assert context.region and context.region_data assert context.region and context.region_data
region = context.region region = context.region
@@ -42,14 +42,10 @@ class ShowLoads(bpy.types.Operator):
assert context.screen assert context.screen
if event.type == "F5": if event.type == "F5":
LoadsDecorator.update() LoadsDecorator.update()
for area in context.screen.areas: tool.Blender.update_all_viewports(context)
if area.type == "VIEW_3D":
area.tag_redraw()
if event.type == "ESC": if event.type == "ESC":
LoadsDecorator.uninstall() LoadsDecorator.uninstall()
for area in context.screen.areas: tool.Blender.update_all_viewports(context)
if area.type == "VIEW_3D":
area.tag_redraw()
return {"FINISHED"} return {"FINISHED"}
return {"PASS_THROUGH"} return {"PASS_THROUGH"}
@@ -69,9 +65,7 @@ class ShowLoads(bpy.types.Operator):
raise exc raise exc
context.window.cursor_modal_restore() context.window.cursor_modal_restore()
context.window_manager.modal_handler_add(self) context.window_manager.modal_handler_add(self)
for area in context.screen.areas: tool.Blender.update_all_viewports(context)
if area.type == "VIEW_3D":
area.tag_redraw()
return {"RUNNING_MODAL"} return {"RUNNING_MODAL"}
+8
View File
@@ -473,6 +473,14 @@ class Blender(bonsai.core.tool.Blender):
def update_viewport(cls) -> None: def update_viewport(cls) -> None:
cls.get_viewport_context()["area"].tag_redraw() cls.get_viewport_context()["area"].tag_redraw()
@classmethod
def update_all_viewports(cls, context: bpy.types.Context | None = None) -> None:
context = context or bpy.context
assert context.screen
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
@classmethod @classmethod
def force_depsgraph_update(cls) -> None: def force_depsgraph_update(cls) -> None:
"""useful if you need to trigger callbacks like `depsgraph_update_pre`""" """useful if you need to trigger callbacks like `depsgraph_update_pre`"""