diff --git a/hooks/tk-multi-publish2/basic/interface/user_interface.py b/hooks/tk-multi-publish2/basic/interface/user_interface.py index 482ffd7..9985b5a 100644 --- a/hooks/tk-multi-publish2/basic/interface/user_interface.py +++ b/hooks/tk-multi-publish2/basic/interface/user_interface.py @@ -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() diff --git a/hooks/tk-multi-publish2/basic/publishers/publish_animation.py b/hooks/tk-multi-publish2/basic/publishers/publish_animation.py index 65a4cc4..346fc1b 100644 --- a/hooks/tk-multi-publish2/basic/publishers/publish_animation.py +++ b/hooks/tk-multi-publish2/basic/publishers/publish_animation.py @@ -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' @@ -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)