getFirstMatchingChildPrim#
Fully qualified name: isaacsim::foundation::utils::getFirstMatchingChildPrim
- std::optional<std::string> isaacsim::foundation::utils::getFirstMatchingChildPrim(
- const std::string &path,
- std::function<bool(const std::string&)> predicate,
- bool includeSelf = false,
- std::optional<std::size_t> maxDepth = std::nullopt,
Returns the first prim in the subtree rooted at
pathfor whichpredicatereturnstrue.Performs a breadth-first traversal of the default stage. Prims are visited in BFS order; the first one for which
predicatereturnstrueis returned immediately and traversal stops.When
includeSelfisfalsethe root prim is skipped and traversal begins with its direct children. WhenincludeSelfistruethe root is the first candidate tested.When
maxDepthis set, traversal stops as soon as the current prim’s depth exceedsmaxDepth. Because the deque is ordered by depth in BFS order, all remaining items at that point are at the same or greater depth, so the entire search halts immediately.See also
getAllMatchingChildPrims()
- Parameters:
path – [in] USD path of the subtree root on the default stage.
predicate – [in] Callable invoked with the string path of each visited prim; return
trueto select that prim.includeSelf – [in] Whether to test
pathitself before its descendants.maxDepth – [in] Maximum traversal depth relative to
path, wherepathitself is at depth 0 and its direct children at depth 1.std::nulloptmeans unlimited depth. Note that depth is always counted frompathregardless ofincludeSelf, somaxDepth=0combined withincludeSelf=falsevisits no prim at all: the direct children the traversal starts from are already at depth 1. UsemaxDepth=1to visit the direct children.
- Returns:
The path of the first matching prim, or
std::nulloptif no match is found.