See Primitive matching patterns for more information on primitive patterns.
Methods ¶
__init__(pattern=None)
Create a LopSelectionRule object with default settings.
The optional pattern
parameter populates the selection rule with the
supplied pattern string. This is equivalent to creating the rule and then
calling hou.LopSelectionRule.setPathPattern.
collectionAwarePaths(lopnode=None, fallback_to_new_paths=False, stage=None)
→ tuple
of pxr.Sdf.Path
Calculates the scene graph primitive selection using the scene graph from
the LOP node object provided as the lopnode
parameter.
If this selection rule was created with a call to
hou.LopNode.selectionRule the lopnode
parameter is assumed to be
equal to the creator node. As an alternative to providing a LOP node, the
pattern will evalaute over any Usd.Stage
passed as the stage
parameter. If both a LOP node and a Usd.Stage
are provided, the stage
parameter takes priority.
Returns the full paths to every scene graph primitive or collection
matching the selection pattern. Unlike the expandedPaths
method,
collections are not expanded to explicitly list their contents as
primitives. Instead the full path of the collection itself is returned.
If the primitive pattern contains any exclusions the included collections
cannot be accurately tracked, so the results of this method will be the
same as for expandedPaths
.
The fallback_to_new_paths
parameter can be set to True
to allow the
selection rule to return scene graph paths if the pattern consists entirely
of explicit paths which do not correspond to any existing primitives on the
stage. Such paths may be used to express desired scene graph locations
for new primitives. If the pattern contains a mix of existing paths and
new paths, this method will always return only the existing paths. The
new paths in such a scenario can be accessed by calling
hou.LopSelectionRule.newPaths.
expandedPaths(lopnode=None, return_ancestors=False, fallback_to_new_paths=False, stage=None)
→ tuple
of pxr.Sdf.Path
Calculates the scene graph primitive selection using the scene graph from
the LOP node object provided as the lopnode
parameter.
If this selection rule was created with a call to
hou.LopNode.selectionRule the lopnode
parameter is assumed to be
equal to the creator node. As an alternative to providing a LOP node, the
pattern will evalaute over any Usd.Stage
passed as the stage
parameter. If both a LOP node and a Usd.Stage
are provided, the stage
parameter takes priority.
Returns the full paths to every scene graph primitive matching the selection rules. All collections in the path pattern are expanded to list their included prims explicitly.
If return_ancestors
is set to True, after the full set of primitives is
calculated, if there are any primitives with all of their direct children
in the set, the parent primitive is added to the set, and the child
primitives are removed from the set. This reduced set can be very useful
to reduce the number of primitives that need to be modified if the
modification is one that inherits down the scene graph tree (such as
visibility or activation).
The fallback_to_new_paths
parameter can be set to True
to allow the
selection rule to return scene graph paths if the pattern consists entirely
of explicit paths which do not correspond to any existing primitives on the
stage. Such paths may be used to express desired scene graph locations
for new primitives. If the pattern contains a mix of existing paths and
new paths, this method will always return only the existing paths. The
new paths in such a scenario can be accessed by calling
hou.LopSelectionRule.newPaths.
firstPath(lopnode=None, return_ancestors=False, fallback_to_new_paths=False, stage=None)
→ pxr.Sdf.Path
Behaves exactly like hou.LopSelectionRule.expandedPaths, but returns only a single path, which will be the first match (alphabetically sorted) of all matches, or the first new path if no matches are found.
newPaths(lopnode=None, stage=None)
→ tuple
of pxr.Sdf.Path
Calculates the scene graph primitive selection using the scene graph from
the LOP node object provided as the lopnode
parameter.
If this selection rule was created with a call to
hou.LopNode.selectionRule the lopnode
parameter is assumed to be
equal to the creator node. As an alternative to providing a LOP node, the
pattern will evalaute over any Usd.Stage
passed as the stage
parameter. If both a LOP node and a Usd.Stage
are provided, the stage
parameter takes priority.
Nothing will be returned by this method unless the pattern consists entirely of explicit paths. Paths which represent existing primitives on the USD stage are not returned by this method.
lastError()
→ str
Any status or error messages generated the last time expandedPaths
or
collectionAwarePaths
was called. This will generally contain information
about invalid pattern strings.
lastErrorSeverity()
→ hou.severityType
The error status of the last time expandedPaths
or collectionAwarePaths
was called. If this value is anything other than hou.severityType.None
,
the lastError
method will return a string with more information.
lastMayBeTimeVarying()
→ bool
A boolean indicating if the most recent calculation of the members of this selection rule might produce a time varying result. This may occur if the selection rule depends on a time varying attribute such as the transform or bounding box of some primitives.
pathPattern()
→ str
Return the path pattern string used in this selection rule.
setPathPattern(pattern)
Sets the path pattern string used in this selection rule.
See /solaris/pattern.html#syntax for the pattern syntax.
traversalDemands()
→ int
Return an integer value that expresses any demands made on the USD primitives while traversing the scene graph looking for matches.
setTraversalDemands(options)
Set demands that must be met by primitives while traversing the scene graph. These demands are expressed as an integer value. This value can be any combination of the hou.lopTraversalDemands values.
Multiple demands can be combined with the |
operator. The following
builds a rule that will only return USD primitives that are active and
defined:
>>> rule = hou.LopSelectionRule() >>> rule.SetTraversalDemands(hou.lopTraversalDemands.Active | hou.lopTraversalDemands.Defined)
icon()
→ str
Return the icon that should be associated with this selection rule when displaying it in the Scene Graph Tree collection panel.
setIcon(icon)
Set the path to the icon file that should be associated with this selection rule in the Scene Graph Tree collection panel. This string can be a path to an image or SVG file on disk, or the name of any standard Houdini icon.
sourceNode()
→ hou.LopNode or None
Return the LOP node that was used to create this rule, if it was created
by calling hou.LopNode.selectionRule. Otherwise return None
.
sourceNodeInputIndex()
→ int
Return the input index parameter used to create this rule, if it was
created by calling hou.LopNode.selectionRule. Otherwise return -1
.