Jump to content

Adding A String Attribute


doc

Recommended Posts

Hello,

I'm just starting to get my feet wet with this hdk stuff and I've come across a tiny stumbling block.

I'm trying to add a point attribute of type string and I couldn't find an example of how to do

this in $HFS/toolkit/samples/SOP. So I guessed :)

int test = gdp->addPointAttrib(attrName1, sizeof(UT_String),GB_ATTRIB_STRING, 0);

This compiles without a problem and when I MMB on the node houdini says the attribute

exists, but when I bring up the spreadsheet the attribute doesn't appear to be listed.

Any ideas?

Luca

Link to comment
Share on other sites

int test = gdp->addPointAttrib(attrName1, sizeof(UT_String),GB_ATTRIB_STRING, 0);

This compiles without a problem and when I MMB on the node houdini says the attribute

exists, but when I bring up the spreadsheet the attribute doesn't appear to be listed.

Hey Luca, try using GB_ATTRIB_INDEX instead of GB_ATTRIB_STRING ... that might completely solve the trick, and will certainly get you closer otherwise. You have to do the same thing when using the HDK to read string values (which is a real pain). For example:

int texOffset = gdp->findPointAttrib( "texname", GB_ATTRIB_INDEX );
GB_Attribute *texAttr = gdp->pointAttribs().find( "texname", GB_ATTRIB_INDEX );
int *idx = static_cast< int* >( point->getAttribData( texOffset ) );
UT_String texVal = texAttr->getIndex( *idx );

Cheers!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...