アトリビュートとは、ジオメトリの色々な要素に追加することができるデータのことです。 そのアトリビュートの値は、そのデータの個々の実体を意味し、各アトリビュートに対してジオメトリエレメント毎に1個のアトリビュート値があります。 例えば、HoudiniのGeometry Spreadsheet内のポイントを見てみると、ポイント番号が横にリストされていて、ポイントアトリビュートが上にリストされています。 そのテーブル内にPointアトリビュートの値が格納されています。
アトリビュートには、アトリビュート値の格納先となる要素(ポイント,プリミティブ,頂点)を指定します。 アトリビュートを全体(Detailアトリビュートと呼びます)に指定することもできます。 その場合、ジオメトリ内に1個の実体のアトリビュート値を持ちます。
アトリビュートには、アトリビュート値のデータタイプも指定します。
既存のアトリビュートを検索するには、hou.Geometry.findPointAttrib, hou.Geometry.findPrimAttrib, hou.Geometry.findVertexAttrib, hou.Geometry.findGlobalAttribを使用します。 新しくアトリビュートを追加するには、hou.Geometry.addAttribを使用します。
Note
ポイントの位置はP
Pointアトリビュートに、ポイントのウェイトはPw
に保存されています。
詳細は、hou.Point.positionとhou.Point.weightを参照してください。
メソッド ¶
name()
→ str
アトリビュートの名前を返します。ジオメトリ内の各アトリビュートは固有の名前を持ちます。
type()
→ hou.attribType列挙値
アトリビュートのタイプ(point, primitive, vertex, global)を返します。
dataType()
→ hou.attribData列挙値
アトリビュートのデータタイプ(int, float, string)を返します。
アトリビュートのサイズは、アトリビュート値のフォーマットも決めます。
例えば、データタイプがint
でサイズが3の場合、そのアトリビュート値は3つの整数のタプルになります。
サイズが1の場合、そのアトリビュート値は単に整数になります。
文字列のアトリビュートのサイズは必ず1でなければなりません。
isArrayType()
→ bool
アトリビュートが配列データを含んだタイプ(つまり、Float Array, Integer Array, String Array)の場合はTrueを、そうでない場合はFalseを返します。
qualifier()
→ str
アトリビュートのタイプ修飾子を返します。
この修飾子とは、アトリビュート内に格納されたデータに関する説明です。
アトリビュートが数値表現でない時、またはアトリビュートが擬似Pw
Pointアトリビュートの場合は、空っぽの文字列が返されます。
size()
→ int
アトリビュート値のデータコンポーネントの数を返します。 詳細は、hou.Attrib.dataTypeを参照してください。
setSize()
アトリビュート値のデータコンポーネントの数を設定します。 詳細は、hou.Attrib.dataTypeを参照してください。
defaultValue()
→ int
or float
or str
or tuple
アトリビュートのデフォルト値を返します。 サイズが1のアトリビュートでは単一のint/float/stringを、サイズが2以上のアトリビュートでは値のタプルが返されます。
このメソッドは、アトリビュートを複製する時に役に立ちます。 サンプルは、hou.Geometry.addAttribを参照してください。
strings()
→ tuple of str
このアトリビュートの文字列テーブルを返します。 アトリビュートが文字列でない場合は、空っぽのタプルが返されます。
文字列アトリビュートは、アトリビュートエレメント(つまり、ポイント,プリミティブなど)内に各文字列値を格納しません。 その代わりに、固有の文字列アトリビュート値がアトリビュート内のテーブルに格納され、各アトリビュート値が、その文字列へのインデックスを格納します。
例えば、このアトリビュートがポイントに対して文字列を格納していると仮定します。
すべてのポイントに"foo"
アトリビュート値があれば、その文字列テーブルがまさに("foo",)
で、各ポイントはインデックス0を持ちます。
いくつかのポイントの値を"bar"
に設定すると、Houdiniは文字列テーブルを("foo", "bar")
に追加設定し、それらのポイントはインデックス1を持ちます。
それらのポイントのどれかを"foo"
に戻すと、Houdiniは文字列テーブルを変更せずに、そのポイントにインデックス0を設定します。
文字列アトリビュート値を使用する時、この実装は、あなたからは見えません。 それらのアトリビュートを文字列として取得し設定します。 このメソッドは、文字列テーブルにアクセスする必要がある場合のためだけに用意されています。
replaceString(before, after)
→ bool
Replace a string in the attribute’s string table.
This changes the string value for all elements that had the before
value,
without iterating over all these elements.
You can get the current table of strings using hou.Attrib.strings.
Returns True if an element was replaced. Returns False if the attribute
doesn’t have a string table or before
string wasn’t found.
Note
The attribute drops a table entry when the replacement action would result in a duplicate. All elements are then updated so they point to the remaining entry.
dicts()
→ tuple of dict
Return the dictionary table for this attribute. If the attribute is not a dictionary, returns an empty tuple.
A dictionary attribute does not store each dictionary value inside the attribute element (i.e. point, primitive, etc.). Instead, the unique dictionary attribute values are stored in a table inside the attribute, and each attribute value stores an index to that dictionary.
For example, suppose this attribute stores dictionaries on points. If all
points have the attribute value { "foo" : 1 }
then the dictionary table
will be just ({ "foo" : 1 },)
and each point will store the index 0.
When you set some points' values to { "bar" : 2}
, Houdini adds sets the
dictionary table to ({"foo":1}, {"bar":2})
and sets stores the index 1 in
those points. When you set one of those points back to {"foo":1}
,
Houdini leaves the dictionary table unchanged and stores the index 0 in
that point.
When using dictionary attribute values, this implementation is hidden from you, and you get and set those attributes as dictionaries. This method is provided only in case you need access to the dictionary table.
indexPairPropertyTables()
→ tuple of hou.IndexPairPropertyTable
このアトリビュートのプロパティテーブルを返します。 アトリビュートがインデックスペアでない場合は、空っぽのタプルが返されます。
isTransformedAsNormal()
→ bool
Houdiniがジオメトリをトランスフォーム(例えば回転)させた時に、ジオメトリ内のアトリビュート値が自動的に法線としてトランスフォームされるかどうか返します。
詳細は、transform_as_normal
パラメータのドキュメントのhou.Geometry.addAttribを参照してください。
destroy()
ジオメトリからこのアトリビュートを削除します。通常では、Python定義のSOPのコードからこのメソッドをコールします。
このジオメトリが修正不可なら、hou.GeometryPermissionErrorを引き起こします。
P
またはPw
のPointアトリビュートを壊そうとした場合、hou.OperationFailedを引き起こします。
options()
→ dict
of str
to bool
, int
, float
, str
このアトリビュートに追加したオプションを含んだ辞書を返します。
この辞書の内容は、ジオメトリファイルに保存されます。
hou.Attrib.option, hou.Attrib.setOption, hou.Attrib.removeOptionも参照してください。
option(name)
→ bool
, int
, float
, str
, hou.Vector2, hou.Vector3, hou.Vector4, hou.Quaternion, hou.Matrix3, hou.Matrix4, tuple of int
, or tuple of float
個々のオプションの値を返し、そのオプションがなければNone
を返します。
hou.Attrib.options, hou.Attrib.setOption, hou.Attrib.removeOptionも参照してください。
optionType(name)
→ hou.fieldType列挙値
オプションで格納されたデータのタイプを意味するhou.fieldType列挙値を返します。
その名前でフィールドが存在しなければ、hou.fieldType.NoSuchField
が返されます。
setOption(name, value, type_hint = hou.fieldType::NoSuchField)
オプションの辞書のエントリーを設定します。 詳細は、hou.Attrib.optionsを参照してください。
name
設定するオプションの名前。
value
整数,浮動小数点,文字列, hou.Vector2, hou.Vector3, hou.Vector4, hou.Quaternion, hou.Matrix3, hou.Matrix4, 連番。
type_hint
指定した値のタイプが、求められる正確なhou.fieldTypeを明確に決定するのに不十分な時に、それを決定するのに使用されます。
removeOption(name)
オプションの辞書のエントリーを削除します。詳細は、hou.Attrib.optionsを参照してください。
辞書にこの名前のエントリーがなかった場合、hou.OperationFailedを引き起こします。
dataId()
このアトリビュートの内容を表現したデータIDを返します。
incrementDataId()
このアトリビュートの内容に変更があったことを示すために、データIDを上げます。