Skip to content

Commit

Permalink
Merge pull request #11 from Sharkitty/bugfix/newly_downloaded_workfile
Browse files Browse the repository at this point in the history
Bugfix: Newly downloaded workfile
  • Loading branch information
Sharkitty authored Mar 13, 2024
2 parents fd56d98 + 1a5617f commit 723de90
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
23 changes: 23 additions & 0 deletions openpype/hosts/blender/hooks/pre_set_current_time_to_workfile.py
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(),
],
)
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

0 comments on commit 723de90

Please sign in to comment.