joelvaneenwyk

joelvaneenwyk

About Me

Connect

LOCATION
Not Specified
ウェブサイト

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Multiparm Issues (HDK) 2008年6月10日0:01

Hey Ondrej,

Thanks for the response! I was at a conference last week and have been catching up since, hence the delayed response.

Alright, what I'm looking for is exactly what you described. The issue I'm having is how/when to set that unique name, so that it is always set correctly. What I tried doing was putting the following (pseudo) code in initMultiparmInstance:


for ( int i = 0; i < parms.entries(); i++ )
{
PRM_Parm *parm = parms;
PRM_Template *templ = parm->getTemplatePtr();

if ( isTemplateNameParam(parm) )
{
std::string defaultName = getUniqueName();
templ->setStringDefault( 0, defaultName.c_str() );
}
}


This works for the most part, but not in the case where you insert before due to the problems I mentioned above. Perhaps I am just going about this the wrong way, so do you have a more optimal solution?

Thanks again for the help!

Take care,

–Joel

Multiparm Issues (HDK) 2008年5月23日21:51

I was afraid that would just make it more confusing. Alright, let me try to give a more complete example. Let's say we insert an item into a MultiParam. On initialization, we generate a unique name for that item by looping through all existing entries and ensuring that the name isn't already used. So on first insert, we have:
multiParamName = “MyUniqueName0”;
Then we have a std::map that uses that name as a key. So then we have:
myDataMap = new SpecialData();
Now, that pointer to SpecialData needs to continue to reference the same entry because the MultiParam has other values associated with it like Fade, Description, etc. This is all fine and dandy if you just insert new items at the end of the list. But if you insert an item at the beginning, setting the template value of the parameter doesn't do what we want.

Does that make more sense or did I make it worse?

Thanks for helping me out with this.

–Joel

Multiparm Issues (HDK) 2008年5月23日16:40

Actually, I don't believe you can do that because the names of the parameters in a Multiparam are always sequential. In other words, let's say you have:

* paramName1
* paramName2

If you insert an entry before paramName2, you would have:

* paramName1
* paramName2
* paramName3

For this to work, you would in fact want the last two names to be swapped, because now the data you want attached to the last entry is still attached to the second (the “new”) entry.

Hopefully that makes sense. I suppose you could keep track of this through catching various opChanged events, but it would be somewhat convoluted. Any ideas on how to make this non-painful?

Thanks!

–Joel