Skip to content

Commit d94c796

Browse files
committed
Moved FBX export for turntable to temp folder
1 parent c56d839 commit d94c796

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

core/templates.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ paths:
389389
# level sequence review output from unreal
390390
unreal_movie_publish:
391391
definition: '[sequences/{Sequence}/][{Shot}/]editorial/{YYYY}_{MM}_{DD}/unreal/{level_sequence}_{world}.v{version}.avi'
392+
unreal_shot_publish:
393+
definition: '@shot_root/publish/unreal/{name}.v{version}.nk'
392394

393395
##########################################################################################
394396
# Asset pipeline
@@ -453,7 +455,7 @@ paths:
453455
maya_ue4_turntable_render:
454456
definition: '@asset_root/work/images/{name}_turntable_v{version}.avi'
455457
maya_ue4_turntable_publish:
456-
definition: '@asset_root/review/{name}_turntable_v{version}.avi'
458+
definition: '@asset_root/review/{Asset}_{name}_turntable_v{version}.avi'
457459

458460

459461
#
@@ -571,11 +573,11 @@ paths:
571573
# Unreal
572574
#
573575

574-
# static mesh export from unreal
575-
unreal_asset_fbx_export:
576-
definition: 'shotgun/fbx_export/{name}.fbx'
576+
# Placeholder location for static mesh assets exported from Unreal
577+
# Hook implementation intended to be a starting point for a pipeline
578+
# No context info used in template, developers expected to further customize
577579
unreal_asset_publish:
578-
definition: 'to_publish/{name}.fbx'
580+
definition: 'assets/unrealdemo/exports/{YYYY}_{MM}_{DD}/{name}.fbx'
579581

580582

581583
#

env/includes/engine_locations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ engines.tk-unreal.location:
8484
type: git_branch
8585
path: [email protected]:shotgunsoftware/tk-unreal
8686
branch: master
87-
version: 3d1b3407fb962b85a49b1f8970af4d305aa9ac1d
87+
version: e589cdfe37b7eee89328920c26f913617d4ef5a3
8888

env/includes/settings/tk-multi-publish2.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ settings.tk-multi-publish2.motion_builder.shot_step:
408408
# project
409409
settings.tk-multi-publish2.unreal.project:
410410
collector: "{self}/collector.py:{engine}/tk-multi-publish2/basic/collector.py"
411-
collector_settings:
412-
Work Template: unreal_asset_fbx_export
413411
publish_plugins:
414412
- name: Publish to Shotgun
415413
hook: "{self}/publish_file.py"

hooks/tk-multi-publish2/tk-maya/basic/publish_turntable.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import subprocess
1212
import sys
1313
import shutil
14+
import datetime
1415

1516
HookBaseClass = sgtk.get_hook_baseclass()
1617

@@ -337,23 +338,29 @@ def publish(self, settings, item):
337338

338339
# =======================
339340
# 1. Export the Maya scene to FBX
340-
# The FBX will be exported to the current work folder, but any other
341-
# destination folder could be specified instead
341+
# The FBX will be exported to a temp folder
342+
# Another folder can be specified as long as the name has no spaces
343+
# Spaces are not allowed in command line Unreal Python args
344+
self.parent.ensure_folder_exists(self.temp_folder)
345+
fbx_folder = self.temp_folder
346+
347+
# Get the filename from the work file
342348
work_path = item.properties.get("work_path")
343349
work_path = os.path.normpath(work_path)
344-
345-
# Split the destination path into folder and filename
346-
fbx_folder = os.path.split(work_path)[0]
347350
work_name = os.path.split(work_path)[1]
348-
work_name = os.path.splitext(work_name)[0]
351+
work_name = os.path.splitext(work_name)[0]
349352

350353
# Replace non-word characters in filename, Unreal doesn't like those
351354
# Substitute '_' instead
352355
exp = re.compile(u"\W", re.UNICODE)
353356
work_name = exp.sub("_", work_name)
354357

358+
# Use current time as string as a unique identifier
359+
now = datetime.datetime.now()
360+
timestamp = str(now.hour) + str(now.minute) + str(now.second)
361+
355362
# Replace file extension with .fbx and suffix it with "_turntable"
356-
fbx_name = work_name + "_turntable.fbx"
363+
fbx_name = work_name + "_" + timestamp + "_turntable.fbx"
357364
fbx_output_path = os.path.join(fbx_folder, fbx_name)
358365

359366
# Export the FBX to the given output path
@@ -374,11 +381,8 @@ def publish(self, settings, item):
374381
script_path = os.path.abspath(script_path)
375382

376383
# Workaround for script path with spaces in it
377-
do_temp_folder_cleanup = False
378384
if " " in script_path:
379385
# Make temporary copies of the scripts to a path without spaces
380-
self.parent.ensure_folder_exists(self.temp_folder)
381-
382386
script_destination = self.temp_folder + "unreal_setup_turntable.py"
383387
shutil.copy(script_path, script_destination)
384388
script_path = script_destination
@@ -405,9 +409,6 @@ def publish(self, settings, item):
405409
script_args.append(turntable_map_path)
406410

407411
self._unreal_execute_script(unreal_exec_path, unreal_project_path, script_path, script_args)
408-
409-
if do_temp_folder_cleanup:
410-
shutil.rmtree(self.temp_folder)
411412

412413
# =======================
413414
# 4. Render the turntable to movie.
@@ -502,13 +503,16 @@ def finalize(self, settings, item):
502503
# bump the session file to the next version
503504
# self._save_to_next_version(item.properties["maya_path"], item, _save_session)
504505

505-
# Delete the exported FBX
506-
fbx_path = item.properties.get("temp_fbx_path")
507-
if fbx_path:
508-
try:
509-
os.remove(fbx_path)
510-
except:
511-
pass
506+
# Delete the exported FBX and scripts from the temp folder
507+
shutil.rmtree(self.temp_folder)
508+
509+
# Revive this when Unreal supports spaces in command line Python args
510+
# fbx_path = item.properties.get("temp_fbx_path")
511+
# if fbx_path:
512+
# try:
513+
# os.remove(fbx_path)
514+
# except:
515+
# pass
512516

513517
def _get_version_entity(self, item):
514518
"""

0 commit comments

Comments
 (0)