diff --git a/openpype/hosts/maya/api/__init__.py b/openpype/hosts/maya/api/__init__.py index 17ec7ac56d..0ad1c8ba29 100644 --- a/openpype/hosts/maya/api/__init__.py +++ b/openpype/hosts/maya/api/__init__.py @@ -218,7 +218,8 @@ def on_task_changed(*args): ) -def before_workfile_save(workfile_path, workdir_path): +def before_workfile_save(event): + workdir_path = event.workdir_path if workdir_path: copy_workspace_mel(workdir_path) diff --git a/openpype/pipeline/lib/events.py b/openpype/pipeline/lib/events.py index 9a6bd12f2d..b9ad889383 100644 --- a/openpype/pipeline/lib/events.py +++ b/openpype/pipeline/lib/events.py @@ -31,10 +31,16 @@ class BaseEvent(object): @classmethod def emit(cls, *args, **kwargs): + """Create object of event and emit. + + Args: + Same args as '__init__' expects which may be class specific. + """ from avalon import pipeline obj = cls(*args, **kwargs) pipeline.emit(obj.topic, [obj]) + return obj class BeforeWorkfileSave(BaseEvent): diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index bd666d9d4f..763e0f796d 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -11,6 +11,7 @@ from Qt import QtWidgets, QtCore from avalon import io, api, pipeline from openpype import style +from openpype.pipeline.lib import BeforeWorkfileSave from openpype.tools.utils.lib import ( qt_app_context ) @@ -670,7 +671,7 @@ class FilesWidget(QtWidgets.QWidget): os.path.normpath(self._workfiles_root), work_file ) - pipeline.emit("before.workfile.save", [file_path, self._workdir_path]) + BeforeWorkfileSave.emit(file_path, self._workdir_path) self._enter_session() # Make sure we are in the right session self.host.save_file(file_path)