[Bf-blender-cvs] [06a7afb528d] blender-v3.2-release: Fix T97947: USD will fail to export without file extension

Philipp Oeser noreply at git.blender.org
Wed May 11 16:48:57 CEST 2022


Commit: 06a7afb528d8bdbbed1c07abfadc83fc95682ec4
Author: Philipp Oeser
Date:   Mon May 9 15:19:48 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB06a7afb528d8bdbbed1c07abfadc83fc95682ec4

Fix T97947: USD will fail to export without file extension

Now add a default ".usdc" file extension if no (or the wrong) extension
is given instead of presenting the user with the error that "no suitable
USD plugin to write is found".

This is in line with how other exporters do this.

Maniphest Tasks: T97947

Differential Revision: https://developer.blender.org/D14895

===================================================================

M	source/blender/editors/io/io_usd.c

===================================================================

diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index e0616a0cec3..ca9c2de63a4 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -190,6 +190,20 @@ static void wm_usd_export_draw(bContext *UNUSED(C), wmOperator *op)
   uiItemR(box, ptr, "use_instancing", 0, NULL, ICON_NONE);
 }
 
+static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op)
+{
+  char filepath[FILE_MAX];
+  RNA_string_get(op->ptr, "filepath", filepath);
+
+  if (!BLI_path_extension_check_n(filepath, ".usd", ".usda", ".usdc", NULL)) {
+    BLI_path_extension_ensure(filepath, FILE_MAX, ".usdc");
+    RNA_string_set(op->ptr, "filepath", filepath);
+    return true;
+  }
+
+  return false;
+}
+
 void WM_OT_usd_export(struct wmOperatorType *ot)
 {
   ot->name = "Export USD";
@@ -200,6 +214,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
   ot->exec = wm_usd_export_exec;
   ot->poll = WM_operator_winactive;
   ot->ui = wm_usd_export_draw;
+  ot->check = wm_usd_export_check;
 
   ot->flag = OPTYPE_REGISTER; /* No UNDO possible. */



More information about the Bf-blender-cvs mailing list