Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3663 from kaamaurice/enhancement/blender-ops-refr…
Browse files Browse the repository at this point in the history
…esh-manager

Blender: ops refresh manager after process events
  • Loading branch information
64qam authored Aug 26, 2022
2 parents 1c322df + cf0ac3f commit 627df16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion openpype/hosts/blender/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def lsattrs(attrs: Dict) -> List:
def read(node: bpy.types.bpy_struct_meta_idprop):
"""Return user-defined attributes from `node`"""

data = dict(node.get(pipeline.AVALON_PROPERTY))
data = dict(node.get(pipeline.AVALON_PROPERTY, {}))

# Ignore hidden/internal data
data = {
Expand Down
17 changes: 12 additions & 5 deletions openpype/hosts/blender/api/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# This seems like a good value to keep the Qt app responsive and doesn't slow
# down Blender. At least on macOS I the interace of Blender gets very laggy if
# you make it smaller.
TIMER_INTERVAL: float = 0.01
TIMER_INTERVAL: float = 0.01 if platform.system() == "Windows" else 0.1


class BlenderApplication(QtWidgets.QApplication):
Expand Down Expand Up @@ -164,6 +164,12 @@ def _process_app_events() -> Optional[float]:
dialog.setDetailedText(detail)
dialog.exec_()

# Refresh Manager
if GlobalClass.app:
manager = GlobalClass.app.get_window("WM_OT_avalon_manager")
if manager:
manager.refresh()

if not GlobalClass.is_windows:
if OpenFileCacher.opening_file:
return TIMER_INTERVAL
Expand Down Expand Up @@ -192,10 +198,11 @@ def __init__(self):
self._app = BlenderApplication.get_app()
GlobalClass.app = self._app

bpy.app.timers.register(
_process_app_events,
persistent=True
)
if not bpy.app.timers.is_registered(_process_app_events):
bpy.app.timers.register(
_process_app_events,
persistent=True
)

def execute(self, context):
"""Execute the operator.
Expand Down
8 changes: 7 additions & 1 deletion openpype/hosts/blender/blender_addon/startup/init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from openpype.pipeline import install_host
from openpype.hosts.blender import api

install_host(api)

def register():
install_host(api)


def unregister():
pass

0 comments on commit 627df16

Please sign in to comment.