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):
ClashDecorator.uninstall()
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
tool.Blender.update_all_viewports(context)
return {"FINISHED"}
@@ -1243,9 +1243,7 @@ class SnapManager:
@staticmethod
def _redraw_viewport() -> None:
"""Force 3D viewport redraw."""
for area in bpy.context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
tool.Blender.update_all_viewports()
def build_snap_cache(
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.")
return {"FINISHED"}
assert context.screen
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
tool.Blender.update_all_viewports(context)
assert context.region and context.region_data
region = context.region
@@ -42,14 +42,10 @@ class ShowLoads(bpy.types.Operator):
assert context.screen
if event.type == "F5":
LoadsDecorator.update()
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
tool.Blender.update_all_viewports(context)
if event.type == "ESC":
LoadsDecorator.uninstall()
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
tool.Blender.update_all_viewports(context)
return {"FINISHED"}
return {"PASS_THROUGH"}
@@ -69,9 +65,7 @@ class ShowLoads(bpy.types.Operator):
raise exc
context.window.cursor_modal_restore()
context.window_manager.modal_handler_add(self)
for area in context.screen.areas:
if area.type == "VIEW_3D":
area.tag_redraw()
tool.Blender.update_all_viewports(context)
return {"RUNNING_MODAL"}
+8
View File
@@ -473,6 +473,14 @@ class Blender(bonsai.core.tool.Blender):
def update_viewport(cls) -> None:
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
def force_depsgraph_update(cls) -> None:
"""useful if you need to trigger callbacks like `depsgraph_update_pre`"""