Skip to content

Commit

Permalink
Merge pull request #11 from nfa-vfxim/hotfix/alembic-multiple-root-su…
Browse files Browse the repository at this point in the history
…pport

Hotfix for adding multiple root selections for Alembic animation publishes
  • Loading branch information
mervinvb authored Dec 18, 2024
2 parents 1bab810 + 93ebaea commit 6a1ee23
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
10 changes: 7 additions & 3 deletions hooks/tk-multi-publish2/basic/interface/user_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,24 @@ def change_maya_selection(self):

if len(selection) != 1:
if len(selection) > 1:
error_message = "You can only select 1 root item for exporting. Make multiple publishes for multiple root items or group them together and select the group."
error_message = "You've selected multiple roots, which might result in weird behavior. Try to make multiple publishes for multiple root items or group them together and select the group."
else:
error_message = "You need to select a root item for exporting."

error_dialog = QtWidgets.QMessageBox()
error_dialog.setIcon(QtWidgets.QMessageBox.Critical)
error_dialog.setText(error_message)
error_dialog.setWindowTitle("Selection Error")
error_dialog.exec_()
return

# I have to add multiple root support right now as a hotfix so excuse the bad code
if error_message == "You need to select a root item for exporting.":
return

stored_publish_data = self.publish_model.data(
self.publish_list.currentIndex(), QtCore.Qt.UserRole
)
stored_publish_data.selection = selection[0]
stored_publish_data.selection = "*+*".join(selection)
self.publish_model.save_publish_data()
self.populate_settings_widget()

Expand Down
21 changes: 20 additions & 1 deletion hooks/tk-multi-publish2/basic/publishers/publish_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ def export_and_publish_animation_as_usd(
item: The item that is being published.
"""
cmds.select(clear=True)

if "*+*" in publish_data.selection:
raise ValueError(
"Cannot export multiple objects to USD at once. Please select one root object."
)

cmds.select(publish_data.selection, replace=True)
usd_command = (
'file -force -options ";exportUVs=1;exportSkels=none;exportSkin=none;exportBlendShapes=0'
Expand Down Expand Up @@ -231,16 +237,29 @@ def export_and_publish_animation_as_alembic(
settings: The stored settings for the plugin.
item: The item that is being published.
"""
root_arguments = []
if "*+*" in publish_data.selection:
root_arguments = [
f"-root {selection}"
for selection in publish_data.selection.split("*+*")
]

else:
root_arguments = [f"-root {publish_data.selection}"]

alembic_args = [
"-renderableOnly",
"-writeFaceSets",
"-uvWrite",
"-eulerFilter",
"-writeVisibility",
f"-root {publish_data.selection}",
]
alembic_args += root_arguments
alembic_args += [
f"-fr {publish_data.first_frame} {publish_data.last_frame}",
"-file '{}'".format(item.properties["path"].replace("\\", "/")),
]

abc_export_cmd = f'AbcExport -j "{" ".join(alembic_args)}"'
self.parent.log_debug(f"Executing command: {abc_export_cmd}")
mel.eval(abc_export_cmd)
Expand Down

0 comments on commit 6a1ee23

Please sign in to comment.