If you ask a COP for its attribute data via the hou.CopNode.attrib, you’ll cook the COP and get a read-only hou.DetachedAttrib. Unlike with SOPs and Geometry objects, the result is no longer tied to the COP Node so it stays the same if the COP node recooks or is deleted.
Call hou.DetachedAttrib.freeze to edit a DetachedAttrib. This returns another DetachedAttrib object that’s an independent writeable copy. Writing to the frozen attribute doesn’t affect the earlier read-only versions.
Methods ¶
close()
Resets this object to be an empty object. This stops it holding a reference to the underlying DetachedAttrib data. This will also happen when the object goes out of scope and is garbage collected, but the close() provides exact control over the timing.
DetachedAttrib also supports contexts so the with statement can be used to auto-close the attribute at the with-block end.
dataType()
→ hou.EnumValue
Return the attribute’s data type (int, float or string).
The size of the attribute also determines the format of the attribute
values. For example, if the data type is int and the size is 3,
the attribute value will be a tuple of 3 ints. If the size was 1,
the attribute value would simply be an int.
Note that a string attribute’s size must be 1.
type()
→ hou.EnumValue
Return the type of attribute (point, primitive, vertex, or global).
This is a hint as detached attributes are not actually bound to geometry.
isArrayType()
→ bool
Return True if the attribute is a type that contains array data (i.e. Float Array, Integer Array, String Array) and False otherwise.
numericDataType()
→ hou.EnumValue
Return the numeric (int, float) attribute’s precision.
qualifier()
→ str
Return the attribute’s type qualifier. The qualifier is a description
of the data contained in the attribute. An empty string is returned
if the attribute has no numeric representation or if the
attribute is the pseudo Pw point attribute.
tupleSize()
→ int
Return the number of data components in the attribute value. See hou.Attrib.dataType for more information.
channelCount()
→ int
Return the number of data components in the attribute value. See hou.Attrib.dataType for more information.
length()
→ int64
The number of elements in the detached attribute. This would be the number of points, vertices, or primitives that it was detached from.
onCPU()
→ bool
A DetachedAttrib may be stored on the CPU or GPU. This is true if it is stored on the CPU.
onGPU()
→ bool
A DetachedAttrib may be stored on the CPU or GPU. This is true if it is stored on the GPU.
freeze()
→ hou.DetachedAttrib
Create a writable copy of this and return it.
Note
The actual buffer duplication won’t be done until a write is performed.
isFrozen()
→ bool
Returns if this is frozen, and hence writable.
properties()
→ std::map<std::string,hboost::any>
Returns the properties present on this attribute.
setProperties(std::map<std::string, p)
Replaces the properties with the provided dictionary.
updateProperties(std::map<std::string, p)
Updates the properties with the provided dictionary, replacing any matching keys.
computeMin(channel=0)
→ int
or float
Returns the attribute’s minimum value across all elements of the selected channel.
computeMax(channel=0)
→ int
or float
Returns the attribute’s maximum value across all elements of the selected channel.
computeMinLength()
→ float
Returns the attribute’s minimum Euclidean length value across all the elements.
computeMaxLength()
→ float
Returns the attribute’s maximum Euclidean length value across all the elements.
computeAverage(channel=0)
→ float
Returns the attribute’s average value across all elements of the selected channel.
rawDetachedAttrib()
→ hou.BinaryString
For numeric tuple attributes, return the data as a binary string.
setFromRawDetachedAttrib(values)
Sets the attribute data of numeric tuple attributes from a binary string.