From a60e02e6fd8de2ec090b422fc5443a9cf5beb025 Mon Sep 17 00:00:00 2001 From: alicedegirolamo Date: Mon, 18 Sep 2023 13:48:18 +0200 Subject: [PATCH] LOOKDEVX-1912 - Append a '1' to new primitives names only if the name does not end with a digit. --- lib/usdUfe/ufe/UsdUndoAddNewPrimCommand.cpp | 8 +++++++- test/lib/ufe/testContextOps.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/usdUfe/ufe/UsdUndoAddNewPrimCommand.cpp b/lib/usdUfe/ufe/UsdUndoAddNewPrimCommand.cpp index 9a8f2a6952..8ef6778f2b 100644 --- a/lib/usdUfe/ufe/UsdUndoAddNewPrimCommand.cpp +++ b/lib/usdUfe/ufe/UsdUndoAddNewPrimCommand.cpp @@ -58,8 +58,14 @@ UsdUndoAddNewPrimCommand::UsdUndoAddNewPrimCommand( auto dagSegment = segments[0]; _stage = usdSceneItem->prim().GetStage(); if (_stage) { + + std::string base, suffixStr; + // Append the parent path and the requested name into a full ufe path. - _newUfePath = appendToPath(ufePath, name + '1'); + // Append a '1' to new primitives names if the name does not end with a digit. + _newUfePath = splitNumericalSuffix(name, base, suffixStr) + ? appendToPath(ufePath, name) + : appendToPath(ufePath, name + '1'); // Ensure the requested name is unique. auto newPrimName diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index dc7a660a66..ce51a53d08 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -1141,7 +1141,7 @@ def testMaterialBindingWithNodeDefHandler(self): self.assertTrue(shaderAttrs.hasAttribute("info:id")) self.assertEqual(shaderAttrs.attribute("info:id").get(), shaderName) - self.assertEqual(ufe.PathString.string(shaderItem.path()), "|stage1|stageShape1,/Material1/Red11") + self.assertEqual(ufe.PathString.string(shaderItem.path()), "|stage1|stageShape1,/Material1/Red1") materialHier = ufe.Hierarchy.hierarchy(materialItem) self.assertTrue(materialHier.hasChildren())