forked from ynput/OpenPype
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Sharkitty/bugfix/newly_downloaded_workfile
Bugfix: Newly downloaded workfile
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pathlib import Path | ||
|
||
from openpype.lib import PreLaunchHook | ||
from openpype.hosts.blender import utility_scripts | ||
|
||
|
||
class PreSetWorkfilePublishTime(PreLaunchHook): | ||
app_groups = [ | ||
"blender", | ||
] | ||
|
||
def execute(self): | ||
if self.data.get("source_filepath"): | ||
# Add `set_current_time_to_workfile` script to launch arguments | ||
self.launch_context.launch_args.insert( | ||
self.launch_context.launch_args.index("-P"), | ||
[ | ||
"-P", | ||
Path(utility_scripts.__file__).parent.joinpath( | ||
"set_current_time_to_workfile.py" | ||
).as_posix(), | ||
], | ||
) |
14 changes: 14 additions & 0 deletions
14
openpype/hosts/blender/utility_scripts/set_current_time_to_workfile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import bpy | ||
|
||
from openpype.lib.log import Logger | ||
from openpype.lib.dateutils import get_timestamp | ||
|
||
if __name__ == "__main__": | ||
current_time = get_timestamp() | ||
|
||
log = Logger().get_logger() | ||
log.debug(f"Setting workfile last publish time to {current_time}") | ||
|
||
# Set last publish time to current time | ||
# This script assumes it is only executed in a known up to date workfile | ||
bpy.context.scene["op_published_time"] = current_time |