跳转到内容

attribsize

如果事先知道属性类别,使用 detailattribsizeprimattribsizepointattribsizevertexattribsize 可能会更快。

int  attribsize(<geometry>geometry, string attribclass, string attribute_name)

<geometry>

当在节点上下文(如 wrangle SOP)中运行时,此参数可以是一个表示输入编号(从0开始)的整数,用于读取几何体。

或者,该参数可以是指定要读取的几何体文件(例如 .bgeo)的字符串。在 Houdini 内部运行时,可以是 op:/path/to/sop 引用。

attribclass

可以是 "detail"(或 "global")、"point""prim""vertex" 之一。

也可以使用 "primgroup""pointgroup""vertexgroup"从组中读取

返回值

属性类型的大小。

  • 对于向量类型,返回其分量数量。
  • 对于整数、浮点数或字符串,返回 1
  • 对于数组属性,返回数组中元组的大小。元组大小由 Attribute Create 节点上的 Size 参数控制。

如果属性不存在,返回 0

  • 此函数处理属性的类型。它不会返回属性的大小。不能使用此函数获取字符串或数组值的长度。

示例

// 获取 "defgeo.bgeo" 中位置属性 P 的大小
int size = attribsize("defgeo.bgeo", "point", "P");