Skip to content

Commit

Permalink
Merge pull request #3331 from Autodesk/degiroa/LOOKDEVX-1912/add-new-…
Browse files Browse the repository at this point in the history
…prim-ending-digit-name

LOOKDEVX-1912 - Append 1 to new prim name only if not ending with digit.
  • Loading branch information
seando-adsk authored Sep 20, 2023
2 parents 8223656 + a60e02e commit 64af858
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 64af858

Please sign in to comment.