[HOM]: how to create the string attribute?

   6109   4   1
User Avatar
Member
77 posts
Joined: April 2009
Offline
Hi!

Wonder how to create the string attribute by HOM…

I've tryed:

geo.addAttrib(hou.attribType.Prim, "shaderName“, ”DefaultName" )

Could you help me please?

Thank you in advance!
User Avatar
Member
1906 posts
Joined: Nov. 2006
Online
That looks right to me. What kind of problem are you getting?
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
77 posts
Joined: April 2009
Offline
The problem is:

String attribute are created but empty, without default.
User Avatar
Member
1906 posts
Joined: Nov. 2006
Online
Ah yes. I can see how that might look like it is not working.

String attributes are a bit different than other attributes. Internally they are represented as Index attributes. All the different possible string values are stored in a giant list and each elements value is represented by an index into that list of values. Due to design reasons there isn't a default attribute value for these types of attributes.

If you look at the Attribute Create SOP for example, when you have it set to String, there is only a single String value field; there is no Default value field. This means that it is creating that String attribute and assigning the value to all the entities. However, if you then add more elements later on you will see that they all come in with an initial value of an empty string.

What this means is that Houdini is just using the string you pass as the default_value argument to determine what type of attribute you are trying to create and that you will have to manually assign the string attribute value you want to each element.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
77 posts
Joined: April 2009
Offline
Thank you, dear graham, for your great explanation!
  • Quick Links