getFirstMatchingParentPrim#

Fully qualified name: isaacsim::foundation::utils::getFirstMatchingParentPrim

std::optional<std::string> isaacsim::foundation::utils::getFirstMatchingParentPrim(
const std::string &path,
std::function<bool(const std::string&)> predicate,
bool includeSelf = false,
)#

Returns the first ancestor of path for which predicate returns true.

Walks up the parent chain on the default stage, testing each prim against predicate, and returns the first match. Traversal stops before reaching the stage pseudoroot ("/"); the pseudoroot is never tested or returned.

When includeSelf is false the walk starts from the direct parent of path. When includeSelf is true the walk starts from path itself.

See also

getFirstMatchingChildPrim()

Parameters:
  • path – [in] USD path whose ancestors are searched on the default stage.

  • predicate – [in] Callable invoked with the string path of each ancestor; return true to select that ancestor.

  • includeSelf – [in] Whether to test path itself before walking up to its parents.

Returns:

The path of the first matching ancestor, or std::nullopt if no match is found before reaching the pseudoroot.