refactored the preview animation publish

This commit is contained in:
Kayla Man 2023-10-18 23:39:47 +08:00
parent 3e75b9ec79
commit eae4709775

View file

@ -567,8 +567,8 @@ def get_plugins() -> list:
return plugin_info_list return plugin_info_list
def publish_review_animation(instance, filepath, def publish_review_animation(instance, staging_dir, start,
start, end, fps): end, ext, fps):
"""Function to set up preview arguments in MaxScript. """Function to set up preview arguments in MaxScript.
****For 3dsMax 2024+ ****For 3dsMax 2024+
@ -583,6 +583,9 @@ def publish_review_animation(instance, filepath,
list: job arguments list: job arguments
""" """
job_args = list() job_args = list()
filename = "{0}..{1}".format(instance.name, ext)
filepath = os.path.join(staging_dir, filename)
filepath = filepath.replace("\\", "/")
default_option = f'CreatePreview filename:"{filepath}"' default_option = f'CreatePreview filename:"{filepath}"'
job_args.append(default_option) job_args.append(default_option)
frame_option = f"outputAVI:false start:{start} end:{end} fps:{fps}" # noqa frame_option = f"outputAVI:false start:{start} end:{end} fps:{fps}" # noqa
@ -698,13 +701,14 @@ def publish_preview_sequences(staging_dir, filename,
rt.gc(delayed=True) rt.gc(delayed=True)
def publish_preview_animation(instance, staging_dir, filepath, def publish_preview_animation(
startFrame, endFrame, review_camera): instance, staging_dir,
"""Publish Reivew Animation startFrame, endFrame,
ext, review_camera):
"""Render camera review animation
Args: Args:
instance (pyblish.api.instance): Instance instance (pyblish.api.instance): Instance
staging_dir (str): staging directory
filepath (str): filepath filepath (str): filepath
startFrame (int): start frame startFrame (int): start frame
endFrame (int): end frame endFrame (int): end frame
@ -718,7 +722,6 @@ def publish_preview_animation(instance, staging_dir, filepath,
instance.data["nitrous_viewport"], instance.data["nitrous_viewport"],
instance.data["vp_btn_mgr"]): instance.data["vp_btn_mgr"]):
percentSize = instance.data.get("percentSize") percentSize = instance.data.get("percentSize")
ext = instance.data.get("imageFormat")
rt.completeRedraw() rt.completeRedraw()
publish_preview_sequences( publish_preview_sequences(
staging_dir, instance.name, staging_dir, instance.name,
@ -726,6 +729,7 @@ def publish_preview_animation(instance, staging_dir, filepath,
else: else:
fps = instance.data["fps"] fps = instance.data["fps"]
rt.completeRedraw() rt.completeRedraw()
preview_arg = publish_review_animation( preview_arg = publish_review_animation(instance, staging_dir,
instance, filepath, startFrame, endFrame, fps) startFrame, endFrame,
ext, fps)
rt.execute(preview_arg) rt.execute(preview_arg)