Skip to content

Commit

Permalink
LOOKDEVX-1912 - Append a '1' to new primitives names only if the name…
Browse files Browse the repository at this point in the history
… does not end with a digit.
  • Loading branch information
alicedegirolamo committed Sep 18, 2023
1 parent 974b0a1 commit a60e02e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/usdUfe/ufe/UsdUndoAddNewPrimCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ufe/testContextOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit a60e02e

Please sign in to comment.